示例#1
0
        static private Media _createVideoMedia(string fileName, TagLib.File file)
        {
            VideoMedia media = new VideoMedia();

            media.MediaType = t_MediaType.VIDEO;
            if (file != null)
            {
                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;
                    TagLib.IVideoCodec vcodec = codec as TagLib.IVideoCodec;
                    if (acodec != null && (acodec.MediaTypes & TagLib.MediaTypes.Audio) != TagLib.MediaTypes.None)
                    {
                        media.Bitrate = acodec.AudioBitrate;
                    }
                    if (vcodec != null && (vcodec.MediaTypes & TagLib.MediaTypes.Video) != TagLib.MediaTypes.None)
                    {
                        media.Width  = vcodec.VideoWidth;
                        media.Height = vcodec.VideoHeight;
                    }
                    break;
                }
            }
            else
            {
                media.Title = Path.GetFileNameWithoutExtension(fileName);
            }
            return(media);
        }
 public void FillModel(VideoMedia media)
 {
     Title = media.Title;
     Year = media.Year;
     Bitrate = media.Bitrate;
     Width = media.Width;
     Height = media.Height;
 }
示例#3
0
        private static Media _createVideoMedia(string fileName, TagLib.File file)
        {
            VideoMedia media = new VideoMedia();

            media.MediaType = t_MediaType.VIDEO;
            if (file != null)
            {
                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;
                    TagLib.IVideoCodec vcodec = codec as TagLib.IVideoCodec;
                    if (acodec != null && (acodec.MediaTypes & TagLib.MediaTypes.Audio) != TagLib.MediaTypes.None)
                        media.Bitrate = acodec.AudioBitrate;
                    if (vcodec != null && (vcodec.MediaTypes & TagLib.MediaTypes.Video) != TagLib.MediaTypes.None)
                    {
                        media.Width = vcodec.VideoWidth;
                        media.Height = vcodec.VideoHeight;
                    }
                    break;
                }
            }
            else
                media.Title = Path.GetFileNameWithoutExtension(fileName);
            return media;
        }