/// <summary> /// Stops the currently loaded media and unloads it. /// </summary> public void Stop( ) { if (!IsMediaLoaded) { return; } OnStop( ); Media = null; }
private async void NewMediaOnParsedChanged(object sender, ObjectEventArgs <MediaParsedChangedArgs> e) { if (lastMedia == null) { throw new Exception("No media loaded"); } FileInfo mediaFile = new FileInfo(new Uri(lastMedia.Mrl).LocalPath); VidereMedia media = new VidereMedia(mediaFile) { Duration = lastMedia.Duration, Name = lastMedia.GetMeta(MetaDataType.Title) }; xZune.Vlc.MediaTrack vid = lastMedia.GetTracks( ).FirstOrDefault(O => O.Type == TrackType.Video); if (vid?.VideoTrack != null) { VideoTrack vidTrack = vid.VideoTrack.Value; media.Video = new VideoInfo { Width = vidTrack.Width, Height = vidTrack.Height }; } xZune.Vlc.MediaTrack aud = lastMedia.GetTracks( ).FirstOrDefault(O => O.Type == TrackType.Audio); if (aud?.AudioTrack != null) { AudioTrack audTrack = aud.AudioTrack.Value; media.Audio = new AudioInfo { Channels = audTrack.Channels, Rate = audTrack.Rate }; } await ViderePlayer.MainDispatcher.InvokeAsync(() => OnMediaLoaded( new OnMediaLoadedEventArgs(media))); }
/// <summary> /// Constructor. /// </summary> /// <param name="element">The <see cref="MediaElement"/> for the player.</param> public MediaElementPlayer(MediaElement element) { this.player = element; this.player.MediaOpened += (Sender, Args) => { VidereMedia media = new VidereMedia(lastLoaded) { Duration = this.player.NaturalDuration.TimeSpan, Name = lastLoaded.Name }; OnMediaLoaded(new OnMediaLoadedEventArgs(media)); }; this.player.MediaFailed += (Sender, Args) => OnMediaFailedToLoad(new OnMediaFailedToLoadEventArgs(Args.ErrorException, Media)); VideoFileExtensions = new[] { "mp4", "mkv", "avi" }; AudioFileExtensions = new[] { "mp3", "wav" }; }
/// <summary> /// Calls the <see cref="MediaFailedToLoad"/> event. /// </summary> /// <param name="args">The event args.</param> protected virtual void OnMediaFailedToLoad(OnMediaFailedToLoadEventArgs args) { Media = null; MediaFailedToLoad?.Invoke(this, args); }
/// <summary> /// Calls the <see cref="MediaUnloaded"/> event. /// </summary> /// <param name="args">The event args.</param> protected virtual void OnMediaUnloaded(OnMediaUnloadedEventArgs args) { Media = null; MediaUnloaded?.Invoke(this, args); }
/// <summary> /// Calls the <see cref="MediaLoaded"/> event. /// </summary> /// <param name="args">The event args.</param> protected virtual void OnMediaLoaded(OnMediaLoadedEventArgs args) { Media = args.MediaFile; MediaLoaded?.Invoke(this, args); }
/// <summary> /// Constructor. /// </summary> /// <param name="exception">The exception.</param> /// <param name="file">The <see cref="VidereMedia"/> of the media that failed to load.</param> public OnMediaFailedToLoadEventArgs(Exception exception, VidereMedia file) { this.Exception = exception; this.MediaFile = file; }
/// <summary> /// Constructor. /// </summary> /// <param name="media">The <see cref="VidereMedia"/> of the loaded media.</param> public OnMediaLoadedEventArgs(VidereMedia media) { this.MediaFile = media; }