[vlc-devel] How to initialize VLC instance with qt interface

Oliver Braunsdorf oliver.braunsdorf at gmx.de
Thu Aug 1 12:39:50 CEST 2019


Hi,

I am trying to use libvlc from my own binary to instantiate a new Qt
interface where I can control the player programmatically.
The problem is, that I only manage to get a plain window playing my
video file, but not the Qt interface (no matter what parameters I
provide to libvlc_new(), e.g., --intf=qt | --intf qt | --I qt |...).
Only with --extraintf qt I can get a second VLC instance with the Qt
interface, but I cannot control that one.

Can you point out what I am missing here? Is it not possible to
instantiate a VLC Qt interface like this? (see the C source file that I
attached)

// note: I am using VLC 3.0.6 Vetinari

I'll try to give you a little more context, if you want to read it:
I try to develop a solution to control the VLC player programmatically
from a Rust-Lang program while also giving the user the possibility to
control the player from the Qt Gui. I used
https://github.com/garkimasera/vlc-rs for that. Works fine, but I only
get a plain window playing the video without any Qt control buttons. I
opened an issue here https://github.com/garkimasera/vlc-rs/issues/4 .
The maintainer of vlc-rs gave me the advice to try it with a C
implementation, because vlc-rs is only a thin wrapper and it seems like
the problem more likely resides in libvlc.
So this is why I asked the question here again.

You might say that my goal can be perfectly accomplished by writing a
VLC control plugin. I agree. I also tried that, using
https://wiki.videolan.org/Hacker_Guide/How_To_Write_a_Module/
I managed to get the plugin running with the Qt Interface and jumping
into my little Rust routine. But I got stuck trying to use vlc-rs
because I don't know how to extract a pointer to vlc_instance_t which I
can feed to vlc-rs to use its API.

So maybe you can also give me an advice here on how to get a reference
to vlc_instance_t from the function static int Open(vlc_object_t *obj)
in a VLC module?


I appreciate any hints. Thank you very much!
Oliver
-------------- next part --------------
#include <stdio.h>
#include <vlc/vlc.h>
#include <stdlib.h>

int main() {
    libvlc_instance_t *my_instance;
    
    const char * const vlc_args[] = {
                  "--verbose=1", //be much more verbose then normal for debugging purpose
                  "--intf=qt"
    };

    my_instance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

    if(my_instance == NULL) {
            printf("There was an error initializing VLC\n");
            exit(1);
    } else {
            printf("VLC initialized successfully\n");
    }

    libvlc_media_t *my_media_file;
    my_media_file = libvlc_media_new_path(my_instance, "/home/vlc/Documents/video.mp4");

    libvlc_media_player_t *my_player;
    my_player = libvlc_media_player_new_from_media(my_media_file);

    // Start playing
    libvlc_media_player_play(my_player);

    sleep(5);

    libvlc_media_release(my_media_file);
    libvlc_media_player_release(my_player);
    libvlc_release(my_instance);
}


More information about the vlc-devel mailing list