From ff8b6659f94b6656fbfdf1558f3d38ce5268db77 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Wed, 6 Jan 2021 19:15:36 +0100 Subject: [PATCH] Open up some events --- .../Android/Player/AndroidMediaPlayer.cs | 2 +- .../Platforms/Tizen/Player/TizenMediaPlayer.cs | 13 +++++-------- .../Platforms/Uap/Player/WindowsMediaPlayer.cs | 18 +++++++++--------- .../Platforms/Wpf/Player/WpfMediaPlayer.cs | 12 ++++++------ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs index 6e704f83..9a0baa3f 100644 --- a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs +++ b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs @@ -250,7 +250,7 @@ protected virtual void Initialize() } } - private void Player_VideoSizeChanged(object sender, Com.Google.Android.Exoplayer2.Video.VideoSizeChangedEventArgs e) + protected virtual void Player_VideoSizeChanged(object sender, Com.Google.Android.Exoplayer2.Video.VideoSizeChangedEventArgs e) { VideoWidth = e.Width; VideoHeight = e.Height; diff --git a/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs b/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs index 6bf9ac57..63d33267 100644 --- a/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs +++ b/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs @@ -55,7 +55,7 @@ public override void UpdateVideoPlaceholder(object value) //TODO: Implement placeholder } - protected virtual void Initialize() + public virtual void Initialize() { Player = new TizenPlayer(); Player.ErrorOccurred += Player_ErrorOccurred; @@ -64,23 +64,23 @@ protected virtual void Initialize() Player.BufferingProgressChanged += Player_BufferingProgressChanged; } - private void Player_BufferingProgressChanged(object sender, BufferingProgressChangedEventArgs e) + protected virtual void Player_BufferingProgressChanged(object sender, BufferingProgressChangedEventArgs e) { //TODO: Percent is not correct here MediaManager.Buffered = TimeSpan.FromMilliseconds(e.Percent); } - private void Player_PlaybackCompleted(object sender, EventArgs e) + protected virtual void Player_PlaybackCompleted(object sender, EventArgs e) { MediaManager.OnMediaItemFinished(this, new MediaItemEventArgs(MediaManager.Queue.Current)); } - private void Player_PlaybackInterrupted(object sender, PlaybackInterruptedEventArgs e) + protected virtual void Player_PlaybackInterrupted(object sender, PlaybackInterruptedEventArgs e) { } - private void Player_ErrorOccurred(object sender, PlayerErrorOccurredEventArgs e) + protected virtual void Player_ErrorOccurred(object sender, PlayerErrorOccurredEventArgs e) { MediaManager.OnMediaItemFailed(this, new MediaItemFailedEventArgs(MediaManager.Queue.Current, new Exception(e.ToString()), e.ToString())); } @@ -89,9 +89,6 @@ private void Player_ErrorOccurred(object sender, PlayerErrorOccurredEventArgs e) public VideoView PlayerView => VideoView as VideoView; - public override event BeforePlayingEventHandler BeforePlaying; - public override event AfterPlayingEventHandler AfterPlaying; - public override Task Pause() { Player.Pause(); diff --git a/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs b/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs index 25465a6e..dd87b902 100644 --- a/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs +++ b/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs @@ -103,7 +103,7 @@ public override void UpdateVideoPlaceholder(object value) PlayerView.PlayerView.PosterSource = imageSource; } - public void Initialize() + public virtual void Initialize() { Player = new MediaPlayer(); Player.AudioCategory = MediaPlayerAudioCategory.Media; @@ -121,43 +121,43 @@ public void Initialize() Player.PlaybackSession.SeekCompleted += PlaybackSession_SeekCompleted; } - private void Player_MediaOpened(MediaPlayer sender, object args) + protected virtual void Player_MediaOpened(MediaPlayer sender, object args) { } - private void PlaybackSession_SeekCompleted(MediaPlaybackSession sender, object args) + protected virtual void PlaybackSession_SeekCompleted(MediaPlaybackSession sender, object args) { //TODO: Maybe use this? } - private void PlaybackSession_NaturalVideoSizeChanged(MediaPlaybackSession sender, object args) + protected virtual void PlaybackSession_NaturalVideoSizeChanged(MediaPlaybackSession sender, object args) { VideoHeight = (int)sender.NaturalVideoHeight; VideoWidth = (int)sender.NaturalVideoWidth; } - private void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object args) + protected virtual void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object args) { //TODO: Maybe use this? } - private void PlaybackSession_BufferingProgressChanged(MediaPlaybackSession sender, object args) + protected virtual void PlaybackSession_BufferingProgressChanged(MediaPlaybackSession sender, object args) { MediaManager.Buffered = TimeSpan.FromMilliseconds(sender.BufferingProgress); } - private void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args) + protected virtual void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args) { MediaManager.State = sender.PlaybackState.ToMediaPlayerState(); } - private void Player_MediaFailed(MediaPlayer sender, MediaPlayerFailedEventArgs args) + protected virtual void Player_MediaFailed(MediaPlayer sender, MediaPlayerFailedEventArgs args) { MediaManager.OnMediaItemFailed(this, new MediaItemFailedEventArgs(MediaManager.Queue.Current, new Exception(args.ErrorMessage), args.ErrorMessage)); } - private void Player_MediaEnded(MediaPlayer sender, object args) + protected virtual void Player_MediaEnded(MediaPlayer sender, object args) { MediaManager.OnMediaItemFinished(this, new MediaItemEventArgs(MediaManager.Queue.Current)); } diff --git a/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs b/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs index fcb50363..1220f213 100644 --- a/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs +++ b/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs @@ -83,7 +83,7 @@ public override void UpdateVideoPlaceholder(object value) //TODO: Implement placeholder } - public void Initialize() + public virtual void Initialize() { Application.Current.Dispatcher.Invoke((Action)delegate { @@ -103,29 +103,29 @@ public void Initialize() }); } - private void Player_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e) + protected virtual void Player_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e) { MediaManager.State = MediaPlayerState.Failed; MediaManager.OnMediaItemFailed(this, new MediaItemFailedEventArgs(MediaManager.Queue.Current, e.ErrorException, e.ErrorException.Message)); } - private void Player_BufferingEnded(object sender, EventArgs e) + protected virtual void Player_BufferingEnded(object sender, EventArgs e) { MediaManager.Buffered = TimeSpan.FromMilliseconds(Player.BufferingProgress); } - private void Player_BufferingStarted(object sender, EventArgs e) + protected virtual void Player_BufferingStarted(object sender, EventArgs e) { MediaManager.State = MediaPlayerState.Buffering; MediaManager.Buffered = TimeSpan.FromMilliseconds(Player.BufferingProgress); } - private void Player_MediaOpened(object sender, EventArgs e) + protected virtual void Player_MediaOpened(object sender, EventArgs e) { MediaManager.State = MediaPlayerState.Playing; } - private void Player_MediaEnded(object sender, EventArgs e) + protected virtual void Player_MediaEnded(object sender, EventArgs e) { MediaManager.OnMediaItemFinished(this, new MediaItemEventArgs(MediaManager.Queue.Current)); }