Exemplo n.º 1
0
        /// <summary>
        /// Used to log the DVD attributes.
        /// DVD organization can vary.
        /// Usually, when you open the DVD for playback, you'll see data for titles,
        /// when you play a title, you'll see chapters.
        /// Title 0 is special - it's the table of contents.
        /// Usually, you can click the Top Menu button to go back to the root title.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Player_OpenPlaylistSwitch(object sender, AxWMPLib._WMPOCXEvents_OpenPlaylistSwitchEvent e)
        {
            UseWaitCursor = true;
            listView1.Items.Clear();

            // Set the button states for the Top Menu and Title Menu buttons.
            SetDVDButtonStates();

            // Get the title playlist.
            IWMPPlaylist pTitle         = (IWMPPlaylist)e.pItem;
            IWMPMedia    TitleOrChapter = null;

            // Get the chapter as IWMPMedia.
            TitleOrChapter = pTitle.get_Item(1);

            //Get the attribute count from the chapter and loop through the attributes.
            int iAttCount = TitleOrChapter.attributeCount;

            for (int j = 0; j < iAttCount; j++)
            {
                ListViewItem item = new ListViewItem("DVD Title/Ch");
                String       name = TitleOrChapter.getAttributeName(j);
                item.SubItems.Add(name);
                item.SubItems.Add(TitleOrChapter.getItemInfo(name));

                // Tell the user about DVD navigation options.
                if ("chapterNum" == name)
                {
                    lblStatus.Text = "DVD Chapter Attributes. To view title attributes, change titles.";
                }
                else if ("titleNum" == name)
                {
                    lblStatus.Text = "DVD Title Attributes. To view chapter attributes, change chapters.";
                }

                bool bRO = TitleOrChapter.isReadOnlyItem(name);

                item.SubItems.Add(bRO.ToString());
                listView1.Items.Add(item);
            }

            ListViewItem item2 = new ListViewItem("");

            listView1.Items.Add(item2);

            UseWaitCursor = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Displays the attribute information for a given media-based attribute source.
        /// </summary>
        /// <param name="Source">An AttributeSource specifying the schema to inspect.</param>
        /// <returns>void</returns>
        private void getMetadataFromMedia(AttributeSource Source)
        {
            IWMPPlaylist playlist = null;
            IWMPMedia    media    = null;

            string name = "";

            try
            {
                switch (Source)
                {
                case AttributeSource.CDTrack:
                    playlist = CD.Playlist;
                    break;

                case AttributeSource.CurrentMedia:
                    playlist = Player.currentPlaylist;
                    break;

                default:
                    // Get a playlist filled with media for the specified schema.
                    playlist = MediaCollection.getByAttribute("MediaType", Source.ToString());
                    break;
                }

                if (0 != playlist.count)
                {
                    // Get the first item from the playlist.
                    media = playlist.get_Item(0);
                }
                else
                {
                    throw new EmptyPlaylistException();
                }

                int cAttributes = media.attributeCount;

                // Log the attribute name, value, and writability.
                for (int i = 0; i < cAttributes; i++)
                {
                    name = media.getAttributeName(i);

                    ListViewItem item = new ListViewItem(Source.ToString());

                    item.SubItems.Add(name);
                    item.SubItems.Add(media.getItemInfo(name));
                    bool bRO = media.isReadOnlyItem(name);
                    item.SubItems.Add(bRO.ToString());
                    listView1.Items.Add(item);
                }
            }
            catch (EmptyPlaylistException)
            {
                ListViewItem item3 = new ListViewItem(Source.ToString());
                item3.SubItems.Add("EmptyPlaylistException");
                item3.SubItems.Add("Does your library contain media for this type or source?");
                listView1.Items.Add(item3);
            }
            catch (COMException exc)
            {
                lblStatus.Text = "Exception in getMetadata: " + exc.Message;
            }
            catch
            {
                lblStatus.Text = "Exception in getMetadata.";
                throw;
            }

            // Insert an empty line in the listview.
            ListViewItem item2 = new ListViewItem("");

            listView1.Items.Add(item2);
        }