Пример #1
0
        static private Media _createAudioMedia(string fileName, TagLib.File file)
        {
            AudioMedia media = new AudioMedia();

            media.MediaType = t_MediaType.AUDIO;
            if (file != null)
            {
                media.Artist = file.Tag.FirstPerformer;
                media.Album  = file.Tag.Album;
                media.Year   = file.Tag.Year;
                media.Title  = file.Tag.Title != "" && file.Tag.Title != null ? file.Tag.Title : Path.GetFileNameWithoutExtension(fileName);
                foreach (TagLib.ICodec codec in file.Properties.Codecs)
                {
                    TagLib.IAudioCodec acodec = codec as TagLib.IAudioCodec;
                    if (acodec != null && (acodec.MediaTypes & TagLib.MediaTypes.Audio) != TagLib.MediaTypes.None)
                    {
                        media.Bitrate = acodec.AudioBitrate;
                    }
                    break;
                }
            }
            else
            {
                media.Title = Path.GetFileNameWithoutExtension(fileName);
            }
            return(media);
        }
 public void FillModel(AudioMedia media)
 {
     Title = media.Title;
     Artist = media.Artist;
     Album = media.Album;
     Year = media.Year;
     Bitrate = media.Bitrate;
 }
Пример #3
0
        private static Media _createAudioMedia(string fileName, TagLib.File file)
        {
            AudioMedia media = new AudioMedia();

            media.MediaType = t_MediaType.AUDIO;
            if (file != null)
            {
                media.Artist = file.Tag.FirstPerformer;
                media.Album = file.Tag.Album;
                media.Year = file.Tag.Year;
                media.Title = file.Tag.Title != "" && file.Tag.Title != null ? file.Tag.Title : Path.GetFileNameWithoutExtension(fileName);
                foreach (TagLib.ICodec codec in file.Properties.Codecs)
                {
                    TagLib.IAudioCodec acodec = codec as TagLib.IAudioCodec;
                    if (acodec != null && (acodec.MediaTypes & TagLib.MediaTypes.Audio) != TagLib.MediaTypes.None)
                        media.Bitrate = acodec.AudioBitrate;
                    break;
                }
            }
            else
                media.Title = Path.GetFileNameWithoutExtension(fileName);
            return media;
        }