Beispiel #1
0
        //==========================================================================
        /// <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);
                }
            }
        }