/// <summary> /// Class describing a video file, manipulated using VLC libraries /// </summary> /// <param name="fileName"></param> public Video(string fileName) { FileInfo file = new FileInfo(fileName); bool initialized = false; if (!VideoTools.checkVlcLib()) { throw new Exception("Cannot find the VLC library... Please make sure you're running this application from inside your PinUp folder..."); } try { VlcMediaPlayer mediaPlayer = new VlcMediaPlayer(VideoTools.GetLibVlcLocation(), VideoTools.GetVlcOptionsHeadless(0)); initialized = true; mediaPlayer.SetMedia(file); mediaPlayer.GetMedia().Parse(); this.Duration = mediaPlayer.GetMedia().Duration.TotalSeconds; this.Width = (int)mediaPlayer.GetMedia().TracksInformations[0].Video.Width; this.Height = (int)mediaPlayer.GetMedia().TracksInformations[0].Video.Height; this.FileName = fileName; mediaPlayer.Dispose(); } catch (Exception exc) { if (!initialized) { throw (new Exception("Cannot initialize VLC player library: " + exc.Message)); } else { throw (new Exception("VLC library error: " + exc.Message)); } } }
public VlcMedia GetCurrentMedia() { //EndInit(); if (myVlcMediaPlayer != null) { return(myVlcMediaPlayer.GetMedia()); } return(null); }
// REMOVE: examineForMetadata and dependent methods (now in MediaFile) #region private static ExamineForMetadata method /// <summary> /// Uses the VLC player to extract metadata from the supplied <see cref="MediaFile"/> /// and add it to the file's Metadata property. /// </summary> /// <param name="instance">The <see cref="MediaFile"/> for which to extract metadata.</param> private static void ExamineForMetadata(MediaFile instance) { _player.SetMedia(new FileInfo(instance.Folder + Path.DirectorySeparatorChar + instance.FileName), new string[] { }); VlcMedia media = _player.GetMedia(); // Parse the media - if we don't do this then the metadata isn't available media.Parse(); AddMetadata(instance, "Length", new TimeSpan(_player.Length)); // FIXED: all properties blank except Mrl and Title // FIXED: Title property contains filename, not actual title AddMetadata(instance, "Album", media.Album); AddMetadata(instance, "Artist", media.Artist); AddMetadata(instance, "ArtworkURL", media.ArtworkURL); AddMetadata(instance, "Copyright", media.Copyright); AddMetadata(instance, "Date", media.Date); AddMetadata(instance, "Description", media.Description); AddMetadata(instance, "Duration", media.Duration); AddMetadata(instance, "EncodedBy", media.EncodedBy); AddMetadata(instance, "Genre", media.Genre); AddMetadata(instance, "Language", media.Language); AddMetadata(instance, "Mrl", media.Mrl); AddMetadata(instance, "NowPlaying", media.NowPlaying); AddMetadata(instance, "Publisher", media.Publisher); AddMetadata(instance, "Rating", media.Rating); AddMetadata(instance, "Setting", media.Setting); AddMetadata(instance, "Title", media.Title); AddMetadata(instance, "TrackID", media.TrackID); AddMetadata(instance, "TrackNumber", media.TrackNumber); AddMetadata(instance, "URL", media.URL); foreach (var trackInfo in media.TracksInformations) { AddMetadata(instance, "TracksInformations.Audio.Channels", trackInfo.Audio.Channels); AddMetadata(instance, "TracksInformations.Audio.Rate", trackInfo.Audio.Rate); AddMetadata(instance, "TracksInformations.CodecFourCC", trackInfo.CodecFourcc); AddMetadata(instance, "TracksInformations.CodecName", trackInfo.CodecName); AddMetadata(instance, "TracksInformations.Level", trackInfo.Level); AddMetadata(instance, "TracksInformations.Profile", trackInfo.Profile); AddMetadata(instance, "TracksInformations.Video.Height", trackInfo.Video.Height); AddMetadata(instance, "TracksInformations.Video.Width", trackInfo.Video.Width); } }
public VlcMedia GetCurrentMedia() { EndInit(); return(myVlcMediaPlayer.GetMedia()); }
public VlcMedia GetCurrentMedia() { return(myVlcMediaPlayer.GetMedia()); }