LibVLC.NET in GTK#

前端 未结 1 397
野性不改
野性不改 2021-01-22 01:20

I use LibVLC.NET wrapper in GTK#. And I have already played video using this example:

LibVLCLibrary library = LibVLCLibrary.Load(null);
IntPtr inst, mp, m;

inst         


        
相关标签:
1条回答
  • 2021-01-22 01:25

    Depending on the platform, you need to call libvlc_media_player_set_xwindow (Linux), libvlc_media_player_set_hwnd (Windows), or libvlc_media_player_set_nsobject (OSX).

    The second parameter is an integer that is the handle to the native component that you want to embed the video.

    Toolkits like GTK/GTK# should provide a method on the component that enables you to get this window handler.

    For example this C# code can be used to get the needed window handle from a GTK Widget

    private static Int32 Wid(Widget widget) {
        IntPtr windowPtr = gtk_widget_get_window(widget.Handle);
        if(windowPtr != IntPtr.Zero) {
            IntPtr xidPtr = gdk_x11_drawable_get_xid(windowPtr);
            if(xidPtr != IntPtr.Zero) {
                return xidPtr.ToInt32();
            }
        }
        return 0;
    }
    

    You only need to do this once after you create your media player and the native component, you do not need to do it each time you play media.

    0 讨论(0)
提交回复
热议问题