コード例 #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
        /// <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.Title       = md[MediaMetadata.Title] as string;
                row.Author      = md[MediaMetadata.Author] as string;
                row.AlbumTitle  = md[MediaMetadata.AlbumTitle] as string;
                row.AlbumArtist = md[MediaMetadata.AlbumArtist] as string;
                row.Publisher   = md[MediaMetadata.Publisher] as string;
                row.Genre       = md[MediaMetadata.Genre] as string;

                object o = md[MediaMetadata.TrackNumber];
                if (o == null)
                {
                    row.SetTrackNumberNull();
                }
                else
                {
                    row.TrackNumber = (uint)o;
                }

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

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

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

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

                row.FileName = filename;
            }
        }