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">
<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"/>
<Grid Name="controls" Visibility="Visible">
<Grid.RowDefinitions>
@@ -38,7 +38,7 @@
<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="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>
</Grid>
+42 -53
View File
@@ -40,12 +40,12 @@ namespace FoxTube
{
public string videoId;
private bool miniViewed = false;
private bool miniView = false;
private bool fullScreen = false;
private bool pointerCaptured = false;
public event EventHandler SetFullSize;
public event EventHandler NextClicked;
public event ObjectEventHandler SetFullSize;
public event ObjectEventHandler NextClicked;
CoreCursor cursorBackup = Window.Current.CoreWindow.PointerCursor;
@@ -78,7 +78,7 @@ namespace FoxTube
this.InitializeComponent();
Visibility = Visibility.Collapsed;
if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
miniView.Visibility = Visibility.Collapsed;;
miniViewBtn.Visibility = Visibility.Collapsed;;
volume.Value = Convert.ToDouble(settings.Values["volume"]);
videoSource.AutoPlay = (bool)settings.Values["videoAutoplay"];
@@ -323,7 +323,7 @@ namespace FoxTube
if(!volumePane.IsOpen && !qualityPane.IsOpen && !subsPane.IsOpen)
{
controls.Visibility = Visibility.Collapsed;
if(!miniViewed)
if(!miniView)
touchCentral.Visibility = Visibility.Collapsed;
if (pointerCaptured)
Window.Current.CoreWindow.PointerCursor = null;
@@ -333,7 +333,7 @@ namespace FoxTube
public void UpdateSize()
{
if(miniViewed)
if(miniView)
{
Height = Width * (videoSource.NaturalVideoHeight / videoSource.NaturalVideoWidth);
ApplicationView.GetForCurrentView().TryResizeView(new Size(Width, Height));
@@ -508,26 +508,22 @@ namespace FoxTube
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();
Width = SecretsVault.MainPage.Width;
Height = SecretsVault.MainPage.Height;
fullscreen.Content = "";
fullScreen = false;
SecretsVault.MainPage.Fullscreen(false);
ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
fullscreen.Content = "\xE1D8";
Height = Methods.MainPage.Height;
}
else
{
fullScreen = ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
Width = double.NaN;
ApplicationView.GetForCurrentView().ExitFullScreenMode();
fullscreen.Content = "\xE1D9";
Height = double.NaN;
fullscreen.Content = "";
SecretsVault.MainPage.Fullscreen(true);
}*/
}
}
private void play_Click(object sender, RoutedEventArgs e)
@@ -549,8 +545,9 @@ namespace FoxTube
play.IsEnabled = false;
touchPlay.IsEnabled = false;
play.Content = "";
touchPlay.Content = "";
play.Content = "\xE102";
touchPlay.Content = "\xE102";
break;
case MediaElementState.Paused:
@@ -560,8 +557,8 @@ namespace FoxTube
play.IsEnabled = true;
touchPlay.IsEnabled = true;
play.Content = "";
touchPlay.Content = "";
play.Content = "\xE102";
touchPlay.Content = "\xE102";
break;
case MediaElementState.Playing:
@@ -571,8 +568,8 @@ namespace FoxTube
play.IsEnabled = true;
touchPlay.IsEnabled = true;
play.Content = "";
touchPlay.Content = "";
play.Content = "\xE103";
touchPlay.Content = "\xE103";
break;
default:
@@ -584,19 +581,18 @@ namespace FoxTube
private async void miniView_Click(object sender, RoutedEventArgs e)
{
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
miniView = !miniView;
SetFullSize(this, miniView);
if (fullScreen)
if (miniView)
{
ApplicationView.GetForCurrentView().ExitFullScreenMode();
fullscreen.Content = "";
fullScreen = false;
}
else
SetFullSize.Invoke(this, null);
if (fullScreen)
{
fullscreen.Content = "\xE740";
fullScreen = false;
}
if (!miniViewed)
{
miniViewed = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
@@ -616,15 +612,9 @@ namespace FoxTube
}
else
{
miniViewed = !await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
titleBar.ButtonBackgroundColor = titleBar.BackgroundColor = Colors.Red;
titleBar.ButtonInactiveBackgroundColor = Colors.Red;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = false;
Methods.MainPage.SetTitleBar();
mainControls.Visibility = Visibility.Visible;
header.Visibility = Visibility.Visible;
@@ -705,19 +695,18 @@ namespace FoxTube
if(fullScreen)
{
ApplicationView.GetForCurrentView().ExitFullScreenMode();
fullscreen.Content = "";
fullscreen.Content = "\xE740";
fullScreen = false;
Methods.MainPage.Fullscreen(false);
}
else
SetFullSize.Invoke(this, null);
SetFullSize.Invoke(this, true);
Width = 432;
Height = 243;
Methods.MainPage.MinimizeVideo();
miniViewed = true;
mainControls.Visibility = Visibility.Collapsed;
header.Visibility = Visibility.Collapsed;
@@ -736,13 +725,13 @@ namespace FoxTube
private void maximize_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.MaximizeVideo();
SetFullSize.Invoke(this, null);
Width = double.NaN;
Height = double.NaN;
miniViewed = false;
Methods.MainPage.MaximizeVideo();
mainControls.Visibility = Visibility.Visible;
header.Visibility = Visibility.Visible;
@@ -778,13 +767,13 @@ namespace FoxTube
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);
else if (miniViewed && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
else if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
maximize_Click(this, null);
else if (fullScreen)
fullscreen_Click(this, null);
else if (!miniViewed && !fullScreen)
else if (!miniView && !fullScreen)
fullscreen_Click(this, null);
}
}
+3 -5
View File
@@ -197,7 +197,7 @@ namespace FoxTube
SetTitleBar();
}
private void SetTitleBar()
public void SetTitleBar()
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
@@ -534,15 +534,13 @@ namespace FoxTube
{
grid.RowDefinitions[0].Height = new GridLength(0);
menu.CompactPaneLength = 0;
/*menu.DisplayMode = SplitViewDisplayMode.Overlay;
menu.IsPaneOpen = false;*/
isForcedCollapsed = true;
menu.OpenPaneLength = 0;
}
else
{
grid.RowDefinitions[0].Height = new GridLength(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);
}
@@ -232,15 +232,12 @@ namespace FoxTube.Pages
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)
{
grid.ColumnDefinitions[1].Width = new GridLength(0);
tabs.Visibility = Visibility.Collapsed;
descriptionPanel.Visibility = Visibility.Collapsed;
commandbar.Visibility = Visibility.Collapsed;
mainScroll.Margin = new Thickness(0);
@@ -250,8 +247,6 @@ namespace FoxTube.Pages
}
else
{
tabs.Visibility = Visibility.Visible;
descriptionPanel.Visibility = Visibility.Visible;
commandbar.Visibility = Visibility.Visible;
mainScroll.Margin = new Thickness(0,0,0,50);