コード例 #1
0
        /// <summary>
        /// Used internally to fill a row of a DataSet with metadata for the given media file.
        /// </summary>
        /// <param name="filename">Windows Media File (.wma file)</param></param>
        /// <param name="row">The TrackRow to be filled with data</param>
        private void RetrieveTrackRow(string filename, ref MediaData.TrackRow row)
        {
            MediaData.TrackDataTable tab = new MediaData.TrackDataTable();

            using (MetadataEditor md = new MetadataEditor(filename))
            {
            row.AlbumTitle = md[MediaMetadata.AlbumTitle] as string;
            row.AlbumArtist = md[MediaMetadata.AlbumArtist] as string;
            row.Author = md[MediaMetadata.Author] as string;

            object o = md[MediaMetadata.BitRate];
            if (o == null)
              row.SetBitRateNull();
            else
              row.BitRate = (uint)o;

            row.Composer = md[MediaMetadata.Composer] as string;
            row.Conductor = md[MediaMetadata.Conductor] as string;

            o = md[MediaMetadata.Duration];
            if (o == null)
              row.SetDurationNull();
            else
            {
              row.Duration = new TimeSpan((long)(ulong)o);
            }

            row.FileName = filename;

            o = md[MediaMetadata.FileSize];
            if (o == null)
              row.SetFileSizeNull();
            else
              row.FileSize = (ulong)o;

            row.Genre = md[MediaMetadata.Genre] as string;

            o = md[MediaMetadata.IsProtected];
            if (o == null)
              row.SetIsProtectedNull();
            else
              row.IsProtected = (bool)o;

            row.Lyrics = md[MediaMetadata.Lyrics] as string;
            row.AcoustID = md[MediaMetadata.AcoustID] as string;
            row.MBID = md[MediaMetadata.MBID] as string;
            row.Publisher = md[MediaMetadata.Publisher] as string;
            row.Text = md[MediaMetadata.Text] as string;
            row.Title = md[MediaMetadata.Title] as string;

            o = md[MediaMetadata.TrackNumber];
                if (o == null)
                    row.SetTrackNumberNull();
                else
                    row.TrackNumber = (uint) o;
              }
        }
コード例 #2
0
ファイル: MediaTags.cs プロジェクト: dxzl/mediatag-sharp
        //
        // Returns a list of KeyValuePair objects with name:value ofsong attributes
        //
        // Example: WM/AlbumArtist:Scott Swift
        //---------------------------------------------------------------------------
        public List<KeyValuePair<string, string>> GetSongAttributesWMA(string filePath)
        {
            List<KeyValuePair<string, string>> sl = new List<KeyValuePair<string, string>>();
            MetadataEditor me = new MetadataEditor(filePath);

            foreach (WinMediaLib.Attribute a in me) sl.Add(new KeyValuePair<string, string>(a.Name, a.Value.ToString()));

            return sl;
        }
コード例 #3
0
        /// <summary>
        /// Retrieves structured property information for the given media file.
        /// </summary>
        /// <param name="filename">Windows Media File (.asf, .wma, .wmv file)</param>
        /// <returns>TrackInfo object containing commonly-used fields</returns>
        public TrackInfo RetrieveTrackInfo(string filename)
        {
            TrackInfo ti = new TrackInfo();

            using (MetadataEditor md = new MetadataEditor(filename))
            {
                ti.title = md[MediaMetadata.Title] as string;
                ti.author = md[MediaMetadata.Author] as string;
                ti.albumTitle = md[MediaMetadata.AlbumTitle] as string;
            ti.albumArtist = md[MediaMetadata.AlbumArtist] as string;
            ti.publisher = md[MediaMetadata.Publisher] as string;
            ti.genre = md[MediaMetadata.Genre] as string;
            ti.year = md[MediaMetadata.Year] as string;

            object o = md[MediaMetadata.TrackNumber];
            ti.track = (o == null ? 0 : (uint)o);

            o = md[MediaMetadata.Duration];
            ti.duration = new TimeSpan((o == null ? 0 : (long)(ulong)o));

            o = md[MediaMetadata.BitRate];
            ti.bitRate = (o == null ? 0 : (uint)o);

            o = md[MediaMetadata.IsProtected];
            ti.isProtected = (o == null ? false : (bool)o);

            o = md[MediaMetadata.FileSize];
            ti.fileSize = (o == null ? 0 : (ulong)o);

            ti.lyrics = md[MediaMetadata.Lyrics] as string;
            ti.acoustId = md[MediaMetadata.AcoustID] as string;
            ti.mbId = md[MediaMetadata.MBID] as string;
            ti.text = md[MediaMetadata.Text] as string;
            ti.composer = md[MediaMetadata.Composer] as string;
            ti.conductor = md[MediaMetadata.Conductor] as string;
              }

            return ti;
        }
コード例 #4
0
ファイル: MetadataEditor.cs プロジェクト: dxzl/mediatag-sharp
 public MetadataEnumerator(MetadataEditor editor)
 {
     ed = editor;
 }