public void Start(int Width, int Height) { if (store.Count > 0) { store[0].Stop(); } store.Add(this); this.Width = Width; this.Height = Height; library = LibVLCLibrary.Load(null); inst = library.m_libvlc_new(4, new string[] { ":sout-udp-caching=0", ":udp-caching=0", ":rtsp-caching=0", ":tcp-caching=0" }); //libvlc_new() // Load the VLC engine m = library.libvlc_media_new_location(inst, playurl); // Create a new item mp = library.libvlc_media_player_new_from_media(m); // Create a media player playing environement library.libvlc_media_release(m); // No need to keep the media now vlc_lock_delegate = new LibVLCLibrary.libvlc_video_lock_cb(vlc_lock); vlc_unlock_delegate = new LibVLCLibrary.libvlc_video_unlock_cb(vlc_unlock); vlc_picture_delegate = new LibVLCLibrary.libvlc_video_display_cb(vlc_picture); library.libvlc_video_set_callbacks(mp, vlc_lock_delegate, vlc_unlock_delegate, vlc_picture_delegate); library.libvlc_video_set_format(mp, "RV24", (uint)Width, (uint)Height, (uint)Width * 4); library.libvlc_media_player_play(mp); // play the media_player }
//========================================================================== public void RunTest() { // The original tutorial code can be found at // http://wiki.videolan.org/LibVLC_Tutorial#Sample_LibVLC_Code LibVLCLibrary library = LibVLCLibrary.Load(null); try { IntPtr inst, mp, m; /* Load the VLC engine */ inst = library.libvlc_new(); /* Create a new item */ //m = library.libvlc_media_new_location(inst, null); m = library.libvlc_media_new_path(inst, "F:\\Dropbox\\Music\\days.flac"); /* Create a media player playing environement */ mp = library.libvlc_media_player_new_from_media(m); /* No need to keep the media now */ library.libvlc_media_release(m); /* play the media_player */ library.libvlc_media_player_play(mp); Thread.Sleep(15000); /* Let it play a bit */ /* Stop playing */ library.libvlc_media_player_stop(mp); /* Free the media_player */ library.libvlc_media_player_release(mp); library.libvlc_release(inst); } finally { LibVLCLibrary.Free(library); } }
static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); ////Set libvlc.dll and libvlccore.dll directory path //VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64; ////Set the vlc plugins directory path //VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64; ////Set the startup options //VlcContext.StartupOptions.IgnoreConfig = true; //VlcContext.StartupOptions.LogOptions.LogInFile = true; //VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true; //VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug; ////Initialize the VlcContext //VlcContext.Initialize(); //Application.Run(new Form1()); ////Close the VlcContext //VlcContext.CloseAll(); LibVLCLibrary library = LibVLCLibrary.Load(null); IntPtr inst, mp, m; inst = library.libvlc_new(); // Load the VLC engine m = library.libvlc_media_new_location(inst, "path/to/your/file"); // Create a new item mp = library.libvlc_media_player_new_from_media(m); // Create a media player playing environement library.libvlc_media_release(m); // No need to keep the media now library.libvlc_media_player_play(mp); // play the media_player Thread.Sleep(10000); // Let it play a bit library.libvlc_media_player_stop(mp); // Stop playing library.libvlc_media_player_release(mp); // Free the media_player library.libvlc_release(inst); LibVLCLibrary.Free(library); }