Skip to content

Commit

Permalink
Open up some events
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Jan 6, 2021
1 parent 15ef5aa commit ff8b665
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 5 additions & 8 deletions MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()));
}
Expand All @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
Expand Down
12 changes: 6 additions & 6 deletions MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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));
}
Expand Down

0 comments on commit ff8b665

Please sign in to comment.