Exemplo n.º 1
0
        private Hashtable getMediaInfo(string in_path)
        {
            Hashtable ht = new Hashtable();

            IWMPMedia imed = mp.newMedia(in_path);

            for (int z = 0; z < imed.attributeCount; z++)
            {
                ht.Add(imed.getAttributeName(z), imed.getItemInfo(imed.getAttributeName(z)));
            }
            mp.close();
            return(ht);
        }
Exemplo n.º 2
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.º 3
0
        public void ShowFileInfo(IWMPMedia media)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Media-info for " + media.name);
            sb.AppendLine();
            sb.AppendLine("Attributes:");
            for (int att = 0; att < media.attributeCount; att++)
            {
                string attName = media.getAttributeName(att);
                sb.AppendFormat("{0}: {1}", att, attName);
                sb.AppendLine();
                sb.AppendFormat(" -> {0}", media.getItemInfo(attName));
                sb.AppendLine();

            }
            sb.AppendLine();
            sb.AppendLine("Other:");
            sb.AppendLine();
            sb.AppendFormat("Marker-count: {0}",media.markerCount);

            MessageBox.Show(sb.ToString());
        }
Exemplo n.º 4
0
        public static AudioPlayerItem CreateAudioPlayerItem(WindowsMediaPlayer wmp, String path)
        {
            AudioPlayerItem item = new AudioPlayerItem();

            try
            {
                IWMPMedia media = wmp.newMedia(path);

                if (media.duration > 0)
                {
                    item.Duration = (int)media.duration;
                    item.SetDurationText(item.Duration);
                    item.Title = media.name.Trim();
                    item.Path  = path;

                    for (int i = 0; i < media.attributeCount; i++)
                    {
                        switch (media.getAttributeName(i).ToUpper())
                        {
                        case "ALBUMIDALBUMARTIST":
                            String[] strs = media.getItemInfo(media.getAttributeName(i)).Split(new String[] { "*;*" }, StringSplitOptions.None);

                            if (strs.Length > 0)
                            {
                                item.Album = strs[0].Trim();
                            }
                            if (strs.Length > 1)
                            {
                                item.Artist = strs[1].Trim();
                            }
                            break;

                        case "AUTHOR":
                            item.Author = media.getItemInfo(media.getAttributeName(i)).Trim();
                            break;

                        case "DISPLAYARTIST":
                            if (item.Artist.Length == 0)
                            {
                                item.Artist = media.getItemInfo(media.getAttributeName(i)).Trim();
                            }
                            break;

                        case "TITLE":
                            if (item.Title.Length == 0)
                            {
                                item.Title = media.getItemInfo(media.getAttributeName(i)).Trim();
                            }
                            break;

                        case "WM/ALBUMARTIST":
                            if (item.Artist.Length == 0)
                            {
                                item.Artist = media.getItemInfo(media.getAttributeName(i)).Trim();
                            }
                            break;

                        case "WM/ALBUMTITLE":
                            if (item.Album.Length == 0)
                            {
                                item.Album = media.getItemInfo(media.getAttributeName(i)).Trim();
                            }
                            break;
                        }
                    }

                    if (String.IsNullOrEmpty(item.Artist))
                    {
                        item.Artist = item.Author;
                    }
                }
            }
            catch { return(null); }

            return(item);
        }
Exemplo n.º 5
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);
        }