diff --git a/MediaManager.Forms/VideoView.cs b/MediaManager.Forms/VideoView.cs index 44f8cfe8..313f543f 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; @@ -62,6 +65,9 @@ protected virtual void MediaManager_PropertyChanged(object sender, System.Compon break; case nameof(MediaManager.AutoPlay): AutoPlay = MediaManager.AutoPlay; + break; + case nameof(MediaManager.IsFullWindow): + IsFullWindow = MediaManager.IsFullWindow; break; case nameof(MediaManager.RepeatMode): Repeat = MediaManager.RepeatMode; @@ -150,7 +156,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 +255,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 +316,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/MediaManagerBase.cs b/MediaManager/MediaManagerBase.cs index 8c2a5f58..6ef17c16 100644 --- a/MediaManager/MediaManagerBase.cs +++ b/MediaManager/MediaManagerBase.cs @@ -160,6 +160,13 @@ public bool AutoPlay { get => _autoPlay; set => SetProperty(ref _autoPlay, value); + } + + private bool _isFullWindow = false; + public bool IsFullWindow + { + get => _isFullWindow; + set => SetProperty(ref _isFullWindow, value); } private bool _retryPlayOnFailed = true; 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/Playback/IPlaybackManager.cs b/MediaManager/Playback/IPlaybackManager.cs index 938c91cd..7b7b8a08 100644 --- a/MediaManager/Playback/IPlaybackManager.cs +++ b/MediaManager/Playback/IPlaybackManager.cs @@ -69,6 +69,11 @@ public interface IPlaybackManager : INotifyPropertyChanged /// bool AutoPlay { get; set; } + /// + /// Indicates if the Player is in full screen + /// + bool IsFullWindow { get; set; } + /// /// Will keep the screen on when set to true and a VideoView is on the screen and playing /// 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">