Archived
1
0

Video player fullscreen and compact view modes complete

This commit is contained in:
Michael Gordeev
2018-08-04 22:07:38 +03:00
parent 9edd432ae8
commit c1c038a0a1
4 changed files with 50 additions and 68 deletions
+2 -2
View File
@@ -16,7 +16,7 @@
PointerEntered="UserControl_PointerEntered"> PointerEntered="UserControl_PointerEntered">
<Grid Background="White" Name="grid"> <Grid Background="White" Name="grid">
<MediaElement CurrentStateChanged="videoSource_CurrentStateChanged" AutoPlay="False" Name="videoSource" AreTransportControlsEnabled="False" PosterSource="ms-appx:///Assets/videoThumbSample.png"/> <MediaElement IsDoubleTapEnabled="False" CurrentStateChanged="videoSource_CurrentStateChanged" AutoPlay="False" Name="videoSource" AreTransportControlsEnabled="False" PosterSource="ms-appx:///Assets/videoThumbSample.png"/>
<TextBox Name="subtitleCapture" Visibility="Collapsed" Text="This is subtitle capture" Background="#99000000" VerticalAlignment="Bottom" HorizontalAlignment="Center" Foreground="White" FontSize="24" Padding="10" Margin="0,0,0,100"/> <TextBox Name="subtitleCapture" Visibility="Collapsed" Text="This is subtitle capture" Background="#99000000" VerticalAlignment="Bottom" HorizontalAlignment="Center" Foreground="White" FontSize="24" Padding="10" Margin="0,0,0,100"/>
<Grid Name="controls" Visibility="Visible"> <Grid Name="controls" Visibility="Visible">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -38,7 +38,7 @@
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="closeHeader" Click="close_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE10A;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Close video"/> <Button Name="closeHeader" Click="close_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE10A;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Close video"/>
<Button Name="cast" Click="cast_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xEC15;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Cast to device"/> <Button Name="cast" Click="cast_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xEC15;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Cast to device"/>
<Button Name="miniView" Click="miniView_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE2B3;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center"/> <Button Name="miniViewBtn" Click="miniView_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE2B3;" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
+42 -53
View File
@@ -40,12 +40,12 @@ namespace FoxTube
{ {
public string videoId; public string videoId;
private bool miniViewed = false; private bool miniView = false;
private bool fullScreen = false; private bool fullScreen = false;
private bool pointerCaptured = false; private bool pointerCaptured = false;
public event EventHandler SetFullSize; public event ObjectEventHandler SetFullSize;
public event EventHandler NextClicked; public event ObjectEventHandler NextClicked;
CoreCursor cursorBackup = Window.Current.CoreWindow.PointerCursor; CoreCursor cursorBackup = Window.Current.CoreWindow.PointerCursor;
@@ -78,7 +78,7 @@ namespace FoxTube
this.InitializeComponent(); this.InitializeComponent();
Visibility = Visibility.Collapsed; Visibility = Visibility.Collapsed;
if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
miniView.Visibility = Visibility.Collapsed;; miniViewBtn.Visibility = Visibility.Collapsed;;
volume.Value = Convert.ToDouble(settings.Values["volume"]); volume.Value = Convert.ToDouble(settings.Values["volume"]);
videoSource.AutoPlay = (bool)settings.Values["videoAutoplay"]; videoSource.AutoPlay = (bool)settings.Values["videoAutoplay"];
@@ -323,7 +323,7 @@ namespace FoxTube
if(!volumePane.IsOpen && !qualityPane.IsOpen && !subsPane.IsOpen) if(!volumePane.IsOpen && !qualityPane.IsOpen && !subsPane.IsOpen)
{ {
controls.Visibility = Visibility.Collapsed; controls.Visibility = Visibility.Collapsed;
if(!miniViewed) if(!miniView)
touchCentral.Visibility = Visibility.Collapsed; touchCentral.Visibility = Visibility.Collapsed;
if (pointerCaptured) if (pointerCaptured)
Window.Current.CoreWindow.PointerCursor = null; Window.Current.CoreWindow.PointerCursor = null;
@@ -333,7 +333,7 @@ namespace FoxTube
public void UpdateSize() public void UpdateSize()
{ {
if(miniViewed) if(miniView)
{ {
Height = Width * (videoSource.NaturalVideoHeight / videoSource.NaturalVideoWidth); Height = Width * (videoSource.NaturalVideoHeight / videoSource.NaturalVideoWidth);
ApplicationView.GetForCurrentView().TryResizeView(new Size(Width, Height)); ApplicationView.GetForCurrentView().TryResizeView(new Size(Width, Height));
@@ -508,26 +508,22 @@ namespace FoxTube
private void fullscreen_Click(object sender, RoutedEventArgs e) private void fullscreen_Click(object sender, RoutedEventArgs e)
{ {
videoSource.IsFullWindow = !videoSource.IsFullWindow; fullScreen = !fullScreen;
SetFullSize.Invoke(this, fullScreen);
Methods.MainPage.Fullscreen(fullScreen);
/*SetFullSize.Invoke(this, null); if(fullScreen)
if (fullScreen)
{ {
ApplicationView.GetForCurrentView().ExitFullScreenMode(); ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
Width = SecretsVault.MainPage.Width; fullscreen.Content = "\xE1D8";
Height = SecretsVault.MainPage.Height; Height = Methods.MainPage.Height;
fullscreen.Content = "";
fullScreen = false;
SecretsVault.MainPage.Fullscreen(false);
} }
else else
{ {
fullScreen = ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); ApplicationView.GetForCurrentView().ExitFullScreenMode();
Width = double.NaN; fullscreen.Content = "\xE1D9";
Height = double.NaN; Height = double.NaN;
fullscreen.Content = ""; }
SecretsVault.MainPage.Fullscreen(true);
}*/
} }
private void play_Click(object sender, RoutedEventArgs e) private void play_Click(object sender, RoutedEventArgs e)
@@ -549,8 +545,9 @@ namespace FoxTube
play.IsEnabled = false; play.IsEnabled = false;
touchPlay.IsEnabled = false; touchPlay.IsEnabled = false;
play.Content = ""; play.Content = "\xE102";
touchPlay.Content = ""; touchPlay.Content = "\xE102";
break; break;
case MediaElementState.Paused: case MediaElementState.Paused:
@@ -560,8 +557,8 @@ namespace FoxTube
play.IsEnabled = true; play.IsEnabled = true;
touchPlay.IsEnabled = true; touchPlay.IsEnabled = true;
play.Content = ""; play.Content = "\xE102";
touchPlay.Content = ""; touchPlay.Content = "\xE102";
break; break;
case MediaElementState.Playing: case MediaElementState.Playing:
@@ -571,8 +568,8 @@ namespace FoxTube
play.IsEnabled = true; play.IsEnabled = true;
touchPlay.IsEnabled = true; touchPlay.IsEnabled = true;
play.Content = ""; play.Content = "\xE103";
touchPlay.Content = ""; touchPlay.Content = "\xE103";
break; break;
default: default:
@@ -584,19 +581,18 @@ namespace FoxTube
private async void miniView_Click(object sender, RoutedEventArgs e) private async void miniView_Click(object sender, RoutedEventArgs e)
{ {
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
miniView = !miniView;
SetFullSize(this, miniView);
if (fullScreen) if (miniView)
{ {
ApplicationView.GetForCurrentView().ExitFullScreenMode(); if (fullScreen)
fullscreen.Content = ""; {
fullScreen = false; fullscreen.Content = "\xE740";
} fullScreen = false;
else }
SetFullSize.Invoke(this, null);
if (!miniViewed) await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
{
miniViewed = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
@@ -616,15 +612,9 @@ namespace FoxTube
} }
else else
{ {
miniViewed = !await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default); await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
titleBar.ButtonBackgroundColor = titleBar.BackgroundColor = Colors.Red; Methods.MainPage.SetTitleBar();
titleBar.ButtonInactiveBackgroundColor = Colors.Red;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = false;
mainControls.Visibility = Visibility.Visible; mainControls.Visibility = Visibility.Visible;
header.Visibility = Visibility.Visible; header.Visibility = Visibility.Visible;
@@ -705,19 +695,18 @@ namespace FoxTube
if(fullScreen) if(fullScreen)
{ {
ApplicationView.GetForCurrentView().ExitFullScreenMode(); ApplicationView.GetForCurrentView().ExitFullScreenMode();
fullscreen.Content = ""; fullscreen.Content = "\xE740";
fullScreen = false; fullScreen = false;
Methods.MainPage.Fullscreen(false); Methods.MainPage.Fullscreen(false);
} }
else else
SetFullSize.Invoke(this, null); SetFullSize.Invoke(this, true);
Width = 432; Width = 432;
Height = 243; Height = 243;
Methods.MainPage.MinimizeVideo(); Methods.MainPage.MinimizeVideo();
miniViewed = true;
mainControls.Visibility = Visibility.Collapsed; mainControls.Visibility = Visibility.Collapsed;
header.Visibility = Visibility.Collapsed; header.Visibility = Visibility.Collapsed;
@@ -736,13 +725,13 @@ namespace FoxTube
private void maximize_Click(object sender, RoutedEventArgs e) private void maximize_Click(object sender, RoutedEventArgs e)
{ {
Methods.MainPage.MaximizeVideo();
SetFullSize.Invoke(this, null); SetFullSize.Invoke(this, null);
Width = double.NaN; Width = double.NaN;
Height = double.NaN; Height = double.NaN;
miniViewed = false; Methods.MainPage.MaximizeVideo();
mainControls.Visibility = Visibility.Visible; mainControls.Visibility = Visibility.Visible;
header.Visibility = Visibility.Visible; header.Visibility = Visibility.Visible;
@@ -778,13 +767,13 @@ namespace FoxTube
private void UserControl_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) private void UserControl_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{ {
if (miniViewed && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay) if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay)
miniView_Click(this, null); miniView_Click(this, null);
else if (miniViewed && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default) else if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
maximize_Click(this, null); maximize_Click(this, null);
else if (fullScreen) else if (fullScreen)
fullscreen_Click(this, null); fullscreen_Click(this, null);
else if (!miniViewed && !fullScreen) else if (!miniView && !fullScreen)
fullscreen_Click(this, null); fullscreen_Click(this, null);
} }
} }
+3 -5
View File
@@ -197,7 +197,7 @@ namespace FoxTube
SetTitleBar(); SetTitleBar();
} }
private void SetTitleBar() public void SetTitleBar()
{ {
var titleBar = ApplicationView.GetForCurrentView().TitleBar; var titleBar = ApplicationView.GetForCurrentView().TitleBar;
@@ -534,15 +534,13 @@ namespace FoxTube
{ {
grid.RowDefinitions[0].Height = new GridLength(0); grid.RowDefinitions[0].Height = new GridLength(0);
menu.CompactPaneLength = 0; menu.CompactPaneLength = 0;
/*menu.DisplayMode = SplitViewDisplayMode.Overlay; menu.OpenPaneLength = 0;
menu.IsPaneOpen = false;*/
isForcedCollapsed = true;
} }
else else
{ {
grid.RowDefinitions[0].Height = new GridLength(50); grid.RowDefinitions[0].Height = new GridLength(50);
menu.CompactPaneLength = 50; menu.CompactPaneLength = 50;
//menu.DisplayMode = SplitViewDisplayMode.CompactOverlay; menu.OpenPaneLength = 250;
} }
} }
+3 -8
View File
@@ -92,7 +92,7 @@ namespace FoxTube.Pages
} }
} }
private void Player_NextClicked(object sender, EventArgs e) private void Player_NextClicked(object sender, params object[] e)
{ {
(relatedVideos.Children[0] as VideoCard).Button_Click(this, null); (relatedVideos.Children[0] as VideoCard).Button_Click(this, null);
} }
@@ -232,15 +232,12 @@ namespace FoxTube.Pages
relatedVideos.Children.Add(new VideoCard(video.Id.VideoId)); relatedVideos.Children.Add(new VideoCard(video.Id.VideoId));
} }
private void Player_SetFullSize(object sender, EventArgs e) private void Player_SetFullSize(object sender, params object[] e)
{ {
isExtended = !isExtended; isExtended = (bool)e[0];
if(isExtended) if(isExtended)
{ {
grid.ColumnDefinitions[1].Width = new GridLength(0); grid.ColumnDefinitions[1].Width = new GridLength(0);
tabs.Visibility = Visibility.Collapsed;
descriptionPanel.Visibility = Visibility.Collapsed;
commandbar.Visibility = Visibility.Collapsed; commandbar.Visibility = Visibility.Collapsed;
mainScroll.Margin = new Thickness(0); mainScroll.Margin = new Thickness(0);
@@ -250,8 +247,6 @@ namespace FoxTube.Pages
} }
else else
{ {
tabs.Visibility = Visibility.Visible;
descriptionPanel.Visibility = Visibility.Visible;
commandbar.Visibility = Visibility.Visible; commandbar.Visibility = Visibility.Visible;
mainScroll.Margin = new Thickness(0,0,0,50); mainScroll.Margin = new Thickness(0,0,0,50);