From 77c98b7bae748eb3b948bcac22e8e6b4c25bb44b Mon Sep 17 00:00:00 2001 From: Nacompllo Date: Tue, 13 Apr 2021 13:45:35 +0200 Subject: [PATCH 1/2] A new property called IsFullWindow has been added and implemented for UWP --- MediaManager.Forms/VideoView.cs | 19 ++++++++++++++++++- .../Android/Player/AndroidMediaPlayer.cs | 8 ++++++++ .../Platforms/Ios/Player/IosMediaPlayer.cs | 8 ++++++++ .../Platforms/Mac/Player/MacMediaPlayer.cs | 8 ++++++++ .../Tizen/Player/TizenMediaPlayer.cs | 8 ++++++++ .../Uap/Player/WindowsMediaPlayer.cs | 8 ++++++++ .../Platforms/Wpf/Player/WpfMediaPlayer.cs | 8 ++++++++ MediaManager/Player/IMediaPlayer.cs | 2 ++ MediaManager/Player/MediaPlayerBase.cs | 14 ++++++++++++++ .../Pages/PlayerPage.xaml | 4 ++-- 10 files changed, 84 insertions(+), 3 deletions(-) diff --git a/MediaManager.Forms/VideoView.cs b/MediaManager.Forms/VideoView.cs index 44f8cfe8..42435a23 100644 --- a/MediaManager.Forms/VideoView.cs +++ b/MediaManager.Forms/VideoView.cs @@ -47,6 +47,9 @@ protected virtual void MediaPlayer_PropertyChanged(object sender, System.Compone case nameof(MediaPlayer.VideoPlaceholder): if (MediaPlayer.VideoPlaceholder is ImageSource imageSource) VideoPlaceholder = imageSource; + break; + case nameof(MediaPlayer.IsFullWindow): + IsFullWindow = MediaPlayer.IsFullWindow; break; default: break; @@ -150,7 +153,10 @@ protected virtual void MediaManager_BufferedChanged(object sender, BufferedChang BindableProperty.Create(nameof(Speed), typeof(float), typeof(VideoView), 1.0f, propertyChanged: OnSpeedPropertyChanged, defaultValueCreator: x => MediaManager.Speed); public static readonly BindableProperty VideoPlaceholderProperty = - BindableProperty.Create(nameof(VideoPlaceholder), typeof(ImageSource), typeof(VideoView), null, propertyChanged: OnVideoPlaceholderPropertyChanged, defaultValueCreator: x => MediaManager.MediaPlayer.VideoPlaceholder?.ToImageSource()); + BindableProperty.Create(nameof(VideoPlaceholder), typeof(ImageSource), typeof(VideoView), null, propertyChanged: OnVideoPlaceholderPropertyChanged, defaultValueCreator: x => MediaManager.MediaPlayer.VideoPlaceholder?.ToImageSource()); + + public static readonly BindableProperty IsFullWindowProperty = + BindableProperty.Create(nameof(IsFullWindow), typeof(bool), typeof(VideoView), false, propertyChanged: OnIsFullWindowPropertyChanged, defaultValueCreator: x => MediaManager.MediaPlayer.IsFullWindow); public VideoAspectMode VideoAspect { @@ -246,6 +252,12 @@ public ImageSource VideoPlaceholder { get { return (ImageSource)GetValue(VideoPlaceholderProperty); } set { SetValue(VideoPlaceholderProperty, value); } + } + + public bool IsFullWindow + { + get { return (bool)GetValue(IsFullWindowProperty); } + set { SetValue(IsFullWindowProperty, value); } } private static async void OnSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue) @@ -301,6 +313,11 @@ private static async void OnVideoPlaceholderPropertyChanged(BindableObject binda #endif } + private static void OnIsFullWindowPropertyChanged(BindableObject bindable, object oldValue, object newValue) + { + MediaManager.MediaPlayer.IsFullWindow = (bool)newValue; + } + public virtual void Dispose() { MediaManager.BufferedChanged -= MediaManager_BufferedChanged; diff --git a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs index 9a0baa3f..71445d81 100644 --- a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs +++ b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs @@ -136,6 +136,14 @@ public override void UpdateVideoPlaceholder(object value) PlayerView.UseArtwork = false; } + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + //TODO: Implement isFullWindow + } + protected int lastWindowIndex = -1; protected virtual void Initialize() diff --git a/MediaManager/Platforms/Ios/Player/IosMediaPlayer.cs b/MediaManager/Platforms/Ios/Player/IosMediaPlayer.cs index 897d83bd..2e77158b 100644 --- a/MediaManager/Platforms/Ios/Player/IosMediaPlayer.cs +++ b/MediaManager/Platforms/Ios/Player/IosMediaPlayer.cs @@ -86,6 +86,14 @@ public override void UpdateVideoPlaceholder(object value) } } + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + //TODO: Implement isFullWindow + } + protected override void Initialize() { base.Initialize(); diff --git a/MediaManager/Platforms/Mac/Player/MacMediaPlayer.cs b/MediaManager/Platforms/Mac/Player/MacMediaPlayer.cs index 8ff86688..4b95f6a1 100644 --- a/MediaManager/Platforms/Mac/Player/MacMediaPlayer.cs +++ b/MediaManager/Platforms/Mac/Player/MacMediaPlayer.cs @@ -66,5 +66,13 @@ public override void UpdateVideoPlaceholder(object value) //TODO: Implement placeholder } + + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + //TODO: Implement isFullWindow + } } } diff --git a/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs b/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs index 63d33267..afc49c2b 100644 --- a/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs +++ b/MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs @@ -55,6 +55,14 @@ public override void UpdateVideoPlaceholder(object value) //TODO: Implement placeholder } + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + //TODO: Implement isFullWindow + } + public virtual void Initialize() { Player = new TizenPlayer(); diff --git a/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs b/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs index dd87b902..1f75c546 100644 --- a/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs +++ b/MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs @@ -103,6 +103,14 @@ public override void UpdateVideoPlaceholder(object value) PlayerView.PlayerView.PosterSource = imageSource; } + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + PlayerView.PlayerView.IsFullWindow = isFullWindow; + } + public virtual void Initialize() { Player = new MediaPlayer(); diff --git a/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs b/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs index 1220f213..0cd19547 100644 --- a/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs +++ b/MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs @@ -83,6 +83,14 @@ public override void UpdateVideoPlaceholder(object value) //TODO: Implement placeholder } + public override void UpdateIsFullWindow(bool isFullWindow) + { + if (PlayerView == null) + return; + + //TODO: Implement isFullWindow + } + public virtual void Initialize() { Application.Current.Dispatcher.Invoke((Action)delegate diff --git a/MediaManager/Player/IMediaPlayer.cs b/MediaManager/Player/IMediaPlayer.cs index 7ebbcd0d..1dcdb207 100644 --- a/MediaManager/Player/IMediaPlayer.cs +++ b/MediaManager/Player/IMediaPlayer.cs @@ -45,6 +45,8 @@ public interface IMediaPlayer : IDisposable, INotifyPropertyChanged object VideoPlaceholder { get; set; } + bool IsFullWindow { get; set; } + /// /// Starts playing the MediaItem /// diff --git a/MediaManager/Player/MediaPlayerBase.cs b/MediaManager/Player/MediaPlayerBase.cs index 34692529..0051c12e 100644 --- a/MediaManager/Player/MediaPlayerBase.cs +++ b/MediaManager/Player/MediaPlayerBase.cs @@ -21,6 +21,7 @@ protected virtual void UpdateVideoView() UpdateVideoAspect(VideoAspect); UpdateShowPlaybackControls(ShowPlaybackControls); UpdateVideoPlaceholder(VideoPlaceholder); + UpdateIsFullWindow(IsFullWindow); } protected VideoAspectMode _videoAspect; @@ -77,8 +78,21 @@ public virtual object VideoPlaceholder } } + private bool _isFullWindow; + public virtual bool IsFullWindow + { + get => _isFullWindow; + set + { + if (SetProperty(ref _isFullWindow, value)) + UpdateIsFullWindow(value); + } + } + public abstract void UpdateVideoPlaceholder(object value); + public abstract void UpdateIsFullWindow(bool value); + public event BeforePlayingEventHandler BeforePlaying; public event AfterPlayingEventHandler AfterPlaying; diff --git a/Samples/ElementPlayer.Forms.UI/Pages/PlayerPage.xaml b/Samples/ElementPlayer.Forms.UI/Pages/PlayerPage.xaml index c38e28b2..cfa4a517 100644 --- a/Samples/ElementPlayer.Forms.UI/Pages/PlayerPage.xaml +++ b/Samples/ElementPlayer.Forms.UI/Pages/PlayerPage.xaml @@ -5,13 +5,13 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:viewModels="clr-namespace:ElementPlayer.Core.ViewModels;assembly=ElementPlayer.Core" xmlns:mm="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms" - x:Class="ElementPlayer.Forms.UI.Pages.PlayerPage" + x:Class="ElementPlayer.Forms.UI.Pages.PlayerPage" x:TypeArguments="viewModels:PlayerViewModel">