/// <summary> /// Gets video properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="mP">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static async Task <VideoItem> GetVideoPropertiesAsync(LibVLC libVLC, VideoItem mP, FromType type) { var media = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type); var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false); if (parseStatus == MediaParsedStatus.Failed) { throw new ParseMediaException($"Could not parse {mP.Path}"); } mP.Title = media.Meta(MetadataType.Title); var showName = media.Meta(MetadataType.ShowName); if (string.IsNullOrEmpty(showName)) { showName = media.Meta(MetadataType.Artist); } if (!string.IsNullOrEmpty(showName)) { mP.ShowTitle = showName; } var episodeString = media.Meta(MetadataType.Episode); if (string.IsNullOrEmpty(episodeString)) { episodeString = media.Meta(MetadataType.TrackNumber); } var episode = 0; if (!string.IsNullOrEmpty(episodeString) && int.TryParse(episodeString, out episode)) { mP.Episode = episode; } var episodesTotal = 0; var episodesTotalString = media.Meta(MetadataType.TrackTotal); if (!string.IsNullOrEmpty(episodesTotalString) && int.TryParse(episodesTotalString, out episodesTotal)) { mP.Episodes = episodesTotal; } var videoTrack = media.Tracks.FirstOrDefault(x => x.TrackType == TrackType.Video); mP.Width = videoTrack.Data.Video.Width; mP.Height = videoTrack.Data.Video.Height; var durationLong = media.Duration; var duration = TimeSpan.FromMilliseconds(durationLong); mP.Duration = duration; return(mP); }
/// <summary> /// Gets music properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="mP">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static async Task <TrackItem> GetMusicPropertiesAsync(LibVLC libVLC, TrackItem mP, FromType type) { var media = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type); var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false); if (parseStatus == MediaParsedStatus.Failed) { throw new ParseMediaException($"Could not parse {mP.Path}"); } mP.AlbumArtist = media.Meta(MetadataType.AlbumArtist); mP.Artist = media.Meta(MetadataType.Artist); mP.Album = media.Meta(MetadataType.Album); mP.Title = media.Meta(MetadataType.Title); mP.AlbumArt = media.Meta(MetadataType.ArtworkURL); var yearString = media.Meta(MetadataType.Date); var year = 0; if (int.TryParse(yearString, out year)) { mP.Year = year; } var durationLong = media.Duration; TimeSpan duration = TimeSpan.FromMilliseconds(durationLong); mP.Duration = duration; var trackNbString = media.Meta(MetadataType.TrackNumber); uint trackNbInt = 0; uint.TryParse(trackNbString, out trackNbInt); mP.Tracknumber = trackNbInt; var discNb = media.Meta(MetadataType.DiscNumber); if (discNb != null && discNb.Contains("/")) { // if discNb = "1/2" var discNumDen = discNb.Split('/'); if (discNumDen.Any()) { discNb = discNumDen[0]; } } int.TryParse(discNb, out int discNbInt); mP.DiscNumber = discNbInt; var genre = media.Meta(MetadataType.Genre); mP.Genre = genre; return(mP); }
private void DisplayVideo(string uRL) { LibVLCSharp.Shared.Core.Initialize(); lib = new LibVLC(); var media = new LibVLCSharp.Shared.Media(lib, uRL, FromType.FromLocation); mymedia.MediaPlayer = new MediaPlayer(media) { EnableHardwareDecoding = true }; mymedia.MediaPlayer.Play(); }
public VLCPage(string path) { InitializeComponent(); download.IsVisible = false; LibVLCSharp.Shared.Core.Initialize(); lib = new LibVLC(); var media = new LibVLCSharp.Shared.Media(lib, path, FromType.FromLocation); mymedia.MediaPlayer = new MediaPlayer(media) { EnableHardwareDecoding = true }; mymedia.MediaPlayer.Play(); }
public VLCPage(ChurchMedia path) { InitializeComponent(); medias = path; LibVLCSharp.Shared.Core.Initialize(); lib = new LibVLC(); var media = new LibVLCSharp.Shared.Media(lib, path.filePath, FromType.FromLocation); mymedia.MediaPlayer = new MediaPlayer(media) { EnableHardwareDecoding = true }; mymedia.MediaPlayer.Play(); desc.Text = path.description; }
private CarouselModel CreateNewVideoItem(string modelType, string headline, string subline, string videoUrl) { var media = new LibVLCSharp.Shared.Media(LibVLC, new Uri(videoUrl)); var mediaPlayer = new MediaPlayer(media) { EnableHardwareDecoding = true }; media.Dispose(); mediaPlayer.Stop(); return(new CarouselModel { ModelType = modelType, Headline = headline, Subline = subline, MediaPlayer = mediaPlayer, LibVLC = LibVLC }); }
internal MediaFreedEventArgs(IntPtr mediaPtr) { Media = new Media(mediaPtr); }
internal MediaListWillDeleteItemEventArgs(Media media, int index) : base(media, index) { }
public MediaSubItemTreeAddedEventArgs(IntPtr subItemPtr) { SubItem = new Media(subItemPtr); }
/// <summary> /// Default constructor /// </summary> /// <param name="media">Current node</param> /// <param name="index">Current index</param> internal protected MediaListBaseEventArgs(Media media, int index) { Media = media; Index = index; }
internal MediaListItemDeletedEventArgs(Media media, int index) : base(media, index) { }
public MediaFreedEventArgs(IntPtr mediaPtr) { Media = new Media(mediaPtr); }
internal MediaPlayerMediaChangedEventArgs(IntPtr mediaPtr) { Media = new Media(mediaPtr); }
internal MediaSubItemAddedEventArgs(IntPtr mediaPtr) { SubItem = new Media(mediaPtr); }
public MediaPlayerMediaChangedEventArgs(IntPtr mediaPtr) { Media = new Media(mediaPtr); }
/// <summary> /// Get subitems of media descriptor object. /// </summary> /// <param name="media"></param> public MediaList(Media media) : base(() => Native.LibVLCMediaSubitems(media.NativeReference), Native.LibVLCMediaListRelease) { }
/// <summary> /// Associate media instance with this media list instance. If another /// media instance was present it will be released. The /// MediaList lock should NOT be held upon entering this function. /// </summary> /// <param name="media">media instance to add</param> public void SetMedia(Media media) { Native.LibVLCMediaListSetMedia(NativeReference, media.NativeReference); }
public MediaListPlayerNextItemSetEventArgs(Media media) { Media = media; }
public MediaListWillAddItemEventArgs(Media media, int index) : base(media, index) { }
public MediaListItemAddedEventArgs(Media media, int index) : base(media, index) { }
internal MediaSubItemTreeAddedEventArgs(IntPtr subItemPtr) { SubItem = new Media(subItemPtr); }
public MediaSubItemAddedEventArgs(IntPtr mediaPtr) { SubItem = new Media(mediaPtr); }