//========================================================================== /// <summary> /// Loads the subitem at the provided index. /// </summary> /// <param name="subitemIndex"> /// The zero-based index of the subitem to load; must be between <c>0</c> /// and <see cref="SubitemCount"/>. /// </param> /// <remarks> /// The current media of the media player will be replaced by the subitem /// with the specified index. /// </remarks> public void LoadSubitem(int subitemIndex) { IntPtr media = m_Library.libvlc_media_player_get_media(m_MediaPlayerHandle); if (media != IntPtr.Zero) { try { IntPtr subitems = m_Library.libvlc_media_subitems(media); if (subitems != IntPtr.Zero) { try { IntPtr subitem = IntPtr.Zero; m_Library.libvlc_media_list_lock(subitems); try { int count = m_Library.libvlc_media_list_count(subitems); if ((subitemIndex >= 0) && (subitemIndex < count)) { subitem = m_Library.libvlc_media_list_item_at_index(subitems, 0); } } finally { m_Library.libvlc_media_list_unlock(subitems); } if (subitem != IntPtr.Zero) { try { m_Library.libvlc_media_player_set_media(m_MediaPlayerHandle, subitem); } finally { m_Library.libvlc_media_release(subitem); } } } finally { m_Library.libvlc_media_list_release(subitems); } } } finally { m_Library.libvlc_media_release(media); } } }
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 }