Skip to content

Commit

Permalink
Merge pull request #812 from nacompllo/develop
Browse files Browse the repository at this point in the history
A IsFullWindow new property has been added and implemented for UWP
  • Loading branch information
martijn00 authored Jun 9, 2021
2 parents 654dc2b + 40e1a55 commit e886a1b
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 3 deletions.
22 changes: 21 additions & 1 deletion MediaManager.Forms/VideoView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions MediaManager/MediaManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Ios/Player/IosMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Mac/Player/MacMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Tizen/Player/TizenMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Uap/Player/WindowsMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions MediaManager/Platforms/Wpf/Player/WpfMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions MediaManager/Playback/IPlaybackManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public interface IPlaybackManager : INotifyPropertyChanged
/// </summary>
bool AutoPlay { get; set; }

/// <summary>
/// Indicates if the Player is in full screen
/// </summary>
bool IsFullWindow { get; set; }

/// <summary>
/// Will keep the screen on when set to true and a VideoView is on the screen and playing
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions MediaManager/Player/IMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface IMediaPlayer : IDisposable, INotifyPropertyChanged

object VideoPlaceholder { get; set; }

bool IsFullWindow { get; set; }

/// <summary>
/// Starts playing the MediaItem
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions MediaManager/Player/MediaPlayerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected virtual void UpdateVideoView()
UpdateVideoAspect(VideoAspect);
UpdateShowPlaybackControls(ShowPlaybackControls);
UpdateVideoPlaceholder(VideoPlaceholder);
UpdateIsFullWindow(IsFullWindow);
}

protected VideoAspectMode _videoAspect;
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions Samples/ElementPlayer.Forms.UI/Pages/PlayerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<Button Text="Browse" Command="{Binding BrowseCommand}" />
<Image Source="{Binding Image}" HorizontalOptions="FillAndExpand" HeightRequest="200" />
<mm:VideoView BackgroundColor="Red" VerticalOptions="FillAndExpand" VideoAspect="AspectFit" ShowControls="True" VideoPlaceholder="xamarin_logo.png" />
<mm:VideoView BackgroundColor="Red" VerticalOptions="FillAndExpand" VideoAspect="AspectFit" ShowControls="True" VideoPlaceholder="xamarin_logo.png" IsFullWindow="True" />
</StackLayout>
</ContentPage.Content>
</mvx:MvxContentPage>

0 comments on commit e886a1b

Please sign in to comment.