Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. LibVLCLibrary library = LibVLCLibrary.Load(null);
  2. IntPtr inst, mp, m;
  3.  
  4. inst = library.libvlc_new(); // Load the VLC engine
  5. m = library.libvlc_media_new_location(inst, "path/to/your/file"); // Create a new item
  6. mp = library.libvlc_media_player_new_from_media(m); // Create a media player playing environement
  7. library.libvlc_media_release(m); // No need to keep the media now
  8. library.libvlc_media_player_play(mp); // play the media_player
  9. Thread.Sleep(10000); // Let it play a bit
  10. library.libvlc_media_player_stop(mp); // Stop playing
  11. library.libvlc_media_player_release(mp); // Free the media_player
  12. library.libvlc_release(inst);
  13.  
  14. LibVLCLibrary.Free(library);
  15.  
  16. //==========================================================================
  17. // void libvlc_video_set_format_callbacks (libvlc_media_player_t *mp, libvlc_video_format_cb setup, libvlc_video_cleanup_cb cleanup)
  18.  
  19. //==========================================================================
  20. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  21. public delegate uint libvlc_video_format_cb(ref IntPtr opaque, ref uint chroma, ref uint width, ref uint height, ref uint pitches, ref uint lines);
  22.  
  23. //==========================================================================
  24. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  25. public delegate void libvlc_video_cleanup_cb(IntPtr opaque);
  26.  
  27. //==========================================================================
  28. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  29. private delegate void libvlc_video_set_format_callbacks_signature(IntPtr mp, libvlc_video_format_cb setup, libvlc_video_cleanup_cb cleanup);
  30.  
  31. //==========================================================================
  32. private readonly libvlc_video_set_format_callbacks_signature m_libvlc_video_set_format_callbacks;
  33.  
  34. //==========================================================================
  35. public void libvlc_video_set_format_callbacks(IntPtr mp, libvlc_video_format_cb setup, libvlc_video_cleanup_cb cleanup)
  36. {
  37. VerifyAccess();
  38.  
  39. m_libvlc_video_set_format_callbacks(mp, setup, cleanup);
  40. }
  41.  
  42. /*
  43. void libvlc_media_player_set_nsobject (libvlc_media_player_t *p_mi, void *drawable)
  44. void * libvlc_media_player_get_nsobject (libvlc_media_player_t *p_mi)
  45. void libvlc_media_player_set_agl (libvlc_media_player_t *p_mi, uint32_t drawable)
  46. uint32_t libvlc_media_player_get_agl (libvlc_media_player_t *p_mi)
  47. void libvlc_media_player_set_xwindow (libvlc_media_player_t *p_mi, uint32_t drawable)
  48. uint32_t libvlc_media_player_get_xwindow (libvlc_media_player_t *p_mi)
  49. void libvlc_media_player_set_hwnd (libvlc_media_player_t *p_mi, void *drawable)
  50. void * libvlc_media_player_get_hwnd (libvlc_media_player_t *p_mi)
  51. */
  52.  
  53. private static Int32 Wid(Widget widget) {
  54. IntPtr windowPtr = gtk_widget_get_window(widget.Handle);
  55. if(windowPtr != IntPtr.Zero) {
  56. IntPtr xidPtr = gdk_x11_drawable_get_xid(windowPtr);
  57. if(xidPtr != IntPtr.Zero) {
  58. return xidPtr.ToInt32();
  59. }
  60. }
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement