From f9f0f0aaee28e14f6f81c377de9a54eaa6fb566c Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Fri, 5 Apr 2019 17:49:39 +0300 Subject: [PATCH] Livestreams support on new player --- FoxTube/Assets/Data/Patchnotes.xml | 2 +- FoxTube/Controls/Player/PlayerControls.cs | 15 ++++++++++++++- FoxTube/Controls/Player/VideoPlayer.xaml.cs | 8 ++++++++ FoxTube/Themes/Generic.xaml | 9 ++++++--- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/FoxTube/Assets/Data/Patchnotes.xml b/FoxTube/Assets/Data/Patchnotes.xml index d4d7762..39ac790 100644 --- a/FoxTube/Assets/Data/Patchnotes.xml +++ b/FoxTube/Assets/Data/Patchnotes.xml @@ -1,6 +1,6 @@  - + ### What's new: - Improved stability and speed of the app diff --git a/FoxTube/Controls/Player/PlayerControls.cs b/FoxTube/Controls/Player/PlayerControls.cs index 8b9ae34..dabf9c6 100644 --- a/FoxTube/Controls/Player/PlayerControls.cs +++ b/FoxTube/Controls/Player/PlayerControls.cs @@ -21,6 +21,7 @@ namespace FoxTube public sealed class PlayerControls : MediaTransportControls { public event RoutedEventHandler CloseRequested; + public event RoutedEventHandler LiveRequested; public event MinimodeChangedEventHandler MiniModeChanged; public event RoutedEventHandler NextRequested; @@ -63,6 +64,8 @@ namespace FoxTube (GetTemplateChild("ProgressSlider") as Slider).ValueChanged += ProgressSlider_ValueChanged; + (GetTemplateChild("goLive") as Button).Click += (s, e) => LiveRequested.Invoke(s, e); + if (queue.Count > 0) foreach (Action i in queue) i(); @@ -321,7 +324,17 @@ namespace FoxTube return; } - // TODO: Set up stream UI + (GetTemplateChild("goLive") as Button).Visibility = Visibility.Visible; + (GetTemplateChild("sliderPan") as Grid).Children.Remove(GetTemplateChild("TimeElapsedElement") as TextBlock); + (GetTemplateChild("rightStack") as StackPanel).Children.Insert(0, GetTemplateChild("TimeElapsedElement") as TextBlock); + (GetTemplateChild("TimeElapsedElement") as TextBlock).VerticalAlignment = VerticalAlignment.Center; + (GetTemplateChild("TimeElapsedElement") as TextBlock).FontSize = 18; + (GetTemplateChild("TimeElapsedElement") as TextBlock).Margin = new Thickness(10, 0, 10, 0); + (GetTemplateChild("sliderPan") as Grid).Visibility = Visibility.Collapsed; + (GetTemplateChild("cc") as Button).Visibility = Visibility.Collapsed; + (GetTemplateChild("quality") as Button).Visibility = Visibility.Collapsed; + + Player.Source = url.ToUri(); } } } diff --git a/FoxTube/Controls/Player/VideoPlayer.xaml.cs b/FoxTube/Controls/Player/VideoPlayer.xaml.cs index e36e64f..fde5c2f 100644 --- a/FoxTube/Controls/Player/VideoPlayer.xaml.cs +++ b/FoxTube/Controls/Player/VideoPlayer.xaml.cs @@ -55,6 +55,9 @@ namespace FoxTube else if (item.Snippet.LiveBroadcastContent == "live") { InitializeContols(); + Controls.IsSkipBackwardButtonVisible = false; + Controls.IsSkipForwardButtonVisible = false; + Controls.LiveRequested += Controls_LiveRequested; Controls.SetStream((await new YoutubeClient().GetVideoMediaStreamInfosAsync(item.Id)).HlsLiveStreamUrl); } else @@ -67,6 +70,11 @@ namespace FoxTube Visibility = Visibility.Visible; } + private void Controls_LiveRequested(object sender, RoutedEventArgs e) + { + videoSource.Position = videoSource.NaturalDuration.TimeSpan; + } + public void InitializeContols() { videoSource.Volume = SettingsStorage.Volume; diff --git a/FoxTube/Themes/Generic.xaml b/FoxTube/Themes/Generic.xaml index f95a712..7e2613e 100644 --- a/FoxTube/Themes/Generic.xaml +++ b/FoxTube/Themes/Generic.xaml @@ -1,4 +1,4 @@ - - + - +