メディアファイルのプロパティーの取得と設定

C#でWindowsMediaPlayerのライブラリを使うことでプロパティーを読み出せる。

using System;
using System.Collections.Generic;
using System.Text;
using WMPLib;

namespace WMPMedia
{
    public enum Attributes
    {
        AcquisitionTime, AcquisitionTimeDay, AcquisitionTimeMonth, AcquisitionTimeYear, AcquisitionTimeYearMonth, AcquisitionTimeYearMonthDay, AlbumID, AlbumIDAlbumArtist, AudioFormat, Author, AverageLevel, Bitrate, BuyNow, BuyTickets, CanonicalFileType, ContentDistributorDuration, Copyright, CurrentBitrate, DefaultDate, DisplayArtist, DRMIndividualizedVersion, DRMKeyID, Duration, FileSize, FileType, HMEAlbumTitle, Is_Protected, IsVBR, LinkedFileURL, MediaType, MoreInfo, PeakValue, ProviderLogoURL, ProviderURL, RecordingTime, RecordingTimeDay, RecordingTimeMonth, RecordingTimeYear, RecordingTimeYearMonth, RecordingTimeYearMonthDay, ReleaseDate, ReleaseDateDay, ReleaseDateMonth, ReleaseDateYear, ReleaseDateYearMonth, ReleaseDateYearMonthDay, RequestState, SourceURL, SyncState, SyncState2, Title, TrackingID, UserCustom1, UserCustom2, UserEffectiveRating, UserLastPlayedTime, UserPlayCount, UserPlaycountAfternoon, UserPlaycountEvening, UserPlaycountMorning, UserPlaycountNight, UserPlaycountWeekday, UserPlaycountWeekend, UserRating, UserServiceRating, AlbumArtist, AlbumTitle, Category, Composer, Conductor, ContentDistributor, ContentGroupDescription, EncodingTime, Genre, GenreID, InitialKey, Language, Lyrics, MCDI, MediaClassPrimaryID, MediaClassSecondaryID, Mood, ParentalRating, PartOfSet, Period, ProtectionType, Provider, ProviderRating, ProviderStyle, Publisher, SubscriptionContentID, SubTitle, TrackNumber, UniqueFileIdentifier, WMCollectionGroupID, WMCollectionID, WMContentID, Writer, Year,
    }

    class WMedia
    {
        static void Main()
        {
            WMedia media = new WMedia(new WMPLib.WindowsMediaPlayer().newMedia(@"E:\My Data\My Music\MP3\Classical\Krystian Zimerman, Seiji Ozawa, Boston Symphony Orchestra\Rachmaninov_ Piano Concertos #1 & 2\01 - Rachmaninov_ Piano Concerto #1 In F sharp minor, Op. 1 - 1. Vivace - Moderato - Vivace.mp3"));
            foreach (Attributes a in Enum.GetValues(typeof(Attributes)))
            {
                Console.WriteLine("{0}\t{1}",a.ToString(),media.GetInfo(a));
            }
            Console.ReadKey(true);
        }


        public IWMPMedia Media = null;
        static private WMPLib.WindowsMediaPlayer wmp = new WindowsMediaPlayer();

        public WMedia(IWMPMedia Media)
        {
            this.Media = Media;
        }
        public WMedia(string URL)
        {
            this.Media = wmp.newMedia(URL);
        }
        public string GetInfo(Attributes attr)
        {
            string szattr=attr.ToString();
            if((int)attr > 64)
                szattr="WM/"+szattr;
            return Media.getItemInfo(szattr);
        }
        public void SetInfo(Attributes attr,string value)
        {
            string szattr = attr.ToString();
            if ((int)attr > 64)
                szattr = "WM/" + szattr;
            Media.setItemInfo(szattr,value);
        }

        public override string ToString()
        {
            return Media.name;
        }
    }
}