Video player development 4
This commit is contained in:
+1
-1
@@ -66,7 +66,7 @@ namespace FoxTube
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
rootFrame.Navigate(typeof(SubLayer), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
|
||||
@@ -59,9 +59,7 @@ namespace FoxTube
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Frame root = Window.Current.Content as Frame;
|
||||
MainPage main = root.Content as MainPage;
|
||||
main.GoToChannel(channelId);
|
||||
SecretsVault.SubLayer.Main.GoToChannel(channelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,9 @@
|
||||
<Compile Include="Settings.xaml.cs">
|
||||
<DependentUpon>Settings.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SubLayer.xaml.cs">
|
||||
<DependentUpon>SubLayer.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Translate.xaml.cs">
|
||||
<DependentUpon>Translate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -255,6 +258,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SubLayer.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Translate.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -542,36 +542,6 @@ namespace FoxTube
|
||||
}
|
||||
}
|
||||
|
||||
public static string NormalizeDuration(string code)
|
||||
{
|
||||
Debug.WriteLine(string.Format("Source string: '{0}'", code));
|
||||
string temp = code.Trim('P', 'T', 'S');
|
||||
Debug.WriteLine(string.Format("Trimmed string: '{0}'", temp));
|
||||
temp = temp.Replace('H', '|');
|
||||
temp = temp.Replace('M', '|');
|
||||
if (temp.StartsWith('|'))
|
||||
temp.TrimStart('|');
|
||||
if (temp.EndsWith('|'))
|
||||
temp.TrimEnd('|');
|
||||
Debug.WriteLine(string.Format("End string: '{0}'", temp));
|
||||
string[] arr = temp.Split('|');
|
||||
Debug.WriteLine(string.Format("Array length: {0}", arr.Length));
|
||||
foreach (string str in arr)
|
||||
Debug.WriteLine(str);
|
||||
|
||||
switch(arr.Length)
|
||||
{
|
||||
case 3:
|
||||
return new TimeSpan(Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1]), Convert.ToInt32(arr[2])).ToString();
|
||||
case 2:
|
||||
return new TimeSpan(0, Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1])).ToString();
|
||||
case 1:
|
||||
return new TimeSpan(0, 0, Convert.ToInt32(arr[0])).ToString();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private void searchSuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if(e.AddedItems.Count > 0)
|
||||
|
||||
@@ -7,6 +7,8 @@ using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
@@ -96,5 +98,15 @@ namespace FoxTube
|
||||
#region Authorization service functions
|
||||
|
||||
#endregion
|
||||
|
||||
#region Simplifying stuff
|
||||
public static SubLayer SubLayer
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Window.Current.Content as Frame).Content as SubLayer;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<TextBlock Text="Playback" FontSize="22"/>
|
||||
<ComboBox Margin="0,0,0,10" Width="250" Header="Default video playback quality" Name="quality" SelectionChanged="quality_SelectionChanged">
|
||||
<ComboBoxItem Content="Auto"/>
|
||||
<ComboBoxItem Content="2160p"/>
|
||||
<ComboBoxItem Content="1080p"/>
|
||||
<ComboBoxItem Content="720p"/>
|
||||
<ComboBoxItem Content="480p"/>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<Page
|
||||
x:Class="FoxTube.SubLayer"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FoxTube"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="Black">
|
||||
|
||||
<Grid Name="grid"/>
|
||||
</Page>
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SubLayer : Page
|
||||
{
|
||||
public MainPage Main = new MainPage();
|
||||
public Frame Fullscreen = new Frame();
|
||||
|
||||
Video initialParent;
|
||||
|
||||
public SubLayer()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
grid.Children.Add(Main);
|
||||
grid.Children.Add(Fullscreen);
|
||||
}
|
||||
|
||||
public void EnterFullScreen(VideoPlayer element, Video initParent)
|
||||
{
|
||||
initialParent = initParent;
|
||||
if(grid.Children.Contains(element))
|
||||
{
|
||||
grid.Children.Remove(element);
|
||||
initialParent.SetPlayerBack();
|
||||
initialParent = null;
|
||||
}
|
||||
else
|
||||
grid.Children.Add(element);
|
||||
/*Fullscreen.Content = element;
|
||||
Fullscreen.Visibility = Visibility.Visible;*/
|
||||
}
|
||||
|
||||
public void ExitFullScreen()
|
||||
{
|
||||
grid.Children.RemoveAt(1);
|
||||
initialParent.SetPlayerBack();
|
||||
/*Fullscreen.Content = null;
|
||||
Fullscreen.Visibility = Visibility.Collapsed;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-3
@@ -30,6 +30,8 @@ namespace FoxTube
|
||||
string videoId;
|
||||
Google.Apis.YouTube.v3.Data.Video item;
|
||||
|
||||
VideoPlayer player;
|
||||
|
||||
public Video()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
@@ -45,11 +47,11 @@ namespace FoxTube
|
||||
item = response.Items[0];
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
views.Text = item.Statistics.ViewCount + " views";
|
||||
/*views.Text = item.Statistics.ViewCount + " views";
|
||||
dislikes.Text = item.Statistics.DislikeCount.ToString();
|
||||
likes.Text = item.Statistics.LikeCount.ToString();
|
||||
Debug.WriteLine((double)item.Statistics.DislikeCount / (double)(item.Statistics.DislikeCount + item.Statistics.LikeCount) * 250);
|
||||
dislikeLine.X2 = (double)item.Statistics.DislikeCount / (double)(item.Statistics.DislikeCount + item.Statistics.LikeCount) * 250;
|
||||
dislikeLine.X2 = (double)item.Statistics.DislikeCount / (double)(item.Statistics.DislikeCount + item.Statistics.LikeCount) * 250;*/
|
||||
description.Text = item.Snippet.Description;
|
||||
|
||||
ChannelsResource.ListRequest request1 = SecretsVault.YoutubeService.Channels.List("snippet,contentDetails,statistics");
|
||||
@@ -62,7 +64,21 @@ namespace FoxTube
|
||||
channelName.Text = item.Snippet.ChannelTitle;
|
||||
subscribers.Text = item1.Statistics.SubscriberCount + " subscribers";
|
||||
|
||||
mainContent.Children.Add(new VideoPlayer(id, item1.Snippet.Thumbnails.Medium.Url));
|
||||
player = new VideoPlayer(id, item1.Snippet.Thumbnails.Medium.Url);
|
||||
player.SetFullSize += Player_SetFullSize;
|
||||
|
||||
mainContent.Children.Add(player);
|
||||
}
|
||||
|
||||
private void Player_SetFullSize(object sender, EventArgs e)
|
||||
{
|
||||
mainContent.Children.Clear();
|
||||
SecretsVault.SubLayer.EnterFullScreen(player, this);
|
||||
}
|
||||
|
||||
public void SetPlayerBack()
|
||||
{
|
||||
mainContent.Children.Add(player);
|
||||
}
|
||||
|
||||
private void gotoChannel_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace FoxTube
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((Window.Current.Content as Frame).Content as MainPage).GoToVideo(videoId);
|
||||
SecretsVault.SubLayer.Main.GoToVideo(videoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ namespace FoxTube
|
||||
|
||||
private void channelLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((Window.Current.Content as Frame).Content as MainPage).GoToChannel(item.Snippet.ChannelId);
|
||||
SecretsVault.SubLayer.Main.GoToChannel(item.Snippet.ChannelId);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((Window.Current.Content as Frame).Content as MainPage).GoToVideo(videoId);
|
||||
SecretsVault.SubLayer.Main.GoToVideo(videoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
<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>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Name="header" Background="#7F000000">
|
||||
<!--<Grid.Background>
|
||||
@@ -34,21 +34,34 @@
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Visibility="Collapsed" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" 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="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode"/>
|
||||
<Button Name="miniView" Click="miniView_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Button Visibility="Collapsed" VerticalAlignment="Top" HorizontalAlignment="Right" Name="miniViewExit" Grid.Row="1" Click="miniView_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode"/>
|
||||
<Button Visibility="Collapsed" Margin="0,35,0,0" VerticalAlignment="Top" HorizontalAlignment="Right" Name="miniViewExit" Grid.Row="1" Click="miniView_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Compact view mode"/>
|
||||
<StackPanel Name="touchCentral" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
|
||||
<Button VerticalAlignment="Center" Content="" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="40" Foreground="WhiteSmoke" Name="touchBack10" Click="back10_Click"/>
|
||||
<Button VerticalAlignment="Center" Content="" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="100" Foreground="WhiteSmoke" Name="touchPlay" Click="play_Click"/>
|
||||
<Button VerticalAlignment="Center" Content="" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="40" Foreground="WhiteSmoke" Name="touchFwd30" Click="fwd30_Click"/>
|
||||
</StackPanel>
|
||||
<Button Name="skipAd" Visibility="Collapsed" Grid.Row="1" HorizontalAlignment="Right" Foreground="White" VerticalAlignment="Bottom" Padding="10" BorderBrush="Black" BorderThickness="2" Background="#7E000000">
|
||||
<Button Name="skipAd" Visibility="Collapsed" Margin="0,0,0,25" Grid.Row="1" HorizontalAlignment="Right" Foreground="White" VerticalAlignment="Bottom" Padding="10" BorderBrush="Black" BorderThickness="2" Background="#7E000000">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="30" Margin="0,0,10,0" Text="" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Skip ad" FontSize="30" TextWrapping="WrapWholeWords" MaxWidth="250"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<StackPanel Name="schedulePanel" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="1" BorderBrush="Black" BorderThickness="2" Background="#7E000000" Padding="10" Margin="25" Orientation="Horizontal">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="30" Margin="0,0,10,0" Foreground="White" Text=""/>
|
||||
<StackPanel>
|
||||
<TextBlock Foreground="White" FontWeight="Bold" Text="Stream hasn't started yet"/>
|
||||
<TextBlock Name="scheduleHeader" Foreground="White" Text="Stream schedule:"/>
|
||||
<TextBlock Name="scheduleStart" Foreground="White" Text="Start time: 18-Jun-18 12:12:12 AM"/>
|
||||
<TextBlock Foreground="White" Name="scheduleEnd" Text="End time: 18-Jun-18 12:12:12 AM"/>
|
||||
|
||||
<TextBlock Name="countdownHeader" Foreground="White" FontWeight="Bold" Text="Stream will be started in:" Margin="0,10,0,0"/>
|
||||
<TextBlock Foreground="White" Name="streamCountdown" FontWeight="SemiBold" FontSize="20" Text="1:10:31:48"/>
|
||||
<ToggleButton Content="Enable notification" Foreground="White" Margin="5"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="2" Name="mainControls" Background="#7F000000">
|
||||
<!--<Grid.Background>
|
||||
<AcrylicBrush TintColor="Black" TintOpacity="0.795" BackgroundSource="Backdrop" AlwaysUseFallback="False" Opacity="0.8"/>
|
||||
@@ -62,7 +75,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Click="play_Click" Name="play" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Play"/>
|
||||
<Button Name="next" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Next video"/>
|
||||
<Button Name="next" Click="next_Click" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Next video"/>
|
||||
<Button Name="openVolume" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Volume" Click="openVolume_Click"/>
|
||||
</StackPanel>
|
||||
<Popup Grid.Column="0" Margin="100,-200,50,0" IsOpen="False" IsLightDismissEnabled="True" Name="volumePane">
|
||||
@@ -115,7 +128,7 @@
|
||||
<StackPanel Background="#7F000000" Width="252" Padding="10">
|
||||
<TextBlock Text="Quality" Foreground="White"/>
|
||||
<Line X1="0" X2="232" Stroke="White" StrokeThickness="2"/>
|
||||
<ComboBox Width="232" Name="quality" SelectionChanged="quality_SelectionChanged">
|
||||
<ComboBox Width="232" Name="quality" SelectionChanged="quality_SelectionChanged" SelectedIndex="0">
|
||||
<ComboBoxItem Content="Auto"/>
|
||||
<ComboBoxItem Content="2160P"/>
|
||||
<ComboBoxItem Content="1080p"/>
|
||||
@@ -123,7 +136,7 @@
|
||||
<ComboBoxItem Content="480p"/>
|
||||
<ComboBoxItem Content="360p"/>
|
||||
<ComboBoxItem Content="240p"/>
|
||||
<ComboBoxItem Content="144p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="144p"/>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</Popup>
|
||||
|
||||
+118
-36
@@ -27,6 +27,7 @@ using Windows.Media;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.ViewManagement;
|
||||
using System.Xml;
|
||||
using Windows.ApplicationModel.Core;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -40,7 +41,10 @@ namespace FoxTube
|
||||
private bool fullScreen = false;
|
||||
private bool pointerCaptured = false;
|
||||
|
||||
UIElement rootBackup;
|
||||
public event EventHandler SetFullSize;
|
||||
public event EventHandler NextClicked;
|
||||
|
||||
CoreCursor cursorBackup;
|
||||
|
||||
TimeSpan elapsed;
|
||||
TimeSpan remaining;
|
||||
@@ -55,11 +59,11 @@ namespace FoxTube
|
||||
YouTubeQuality.QualityHigh,
|
||||
YouTubeQuality.Quality2160P,
|
||||
YouTubeQuality.Quality1080P,
|
||||
YouTubeQuality.Quality270P,
|
||||
YouTubeQuality.Quality720P,
|
||||
YouTubeQuality.Quality480P,
|
||||
YouTubeQuality.Quality360P,
|
||||
YouTubeQuality.Quality240P,
|
||||
YouTubeQuality.Quality144P,
|
||||
YouTubeQuality.Quality144P
|
||||
};
|
||||
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
@@ -68,7 +72,13 @@ namespace FoxTube
|
||||
Interval = 5000,
|
||||
Enabled = true
|
||||
};
|
||||
Timer seekTimer = new Timer() { Interval = 1000 };
|
||||
Timer seekTimer = new Timer()
|
||||
{
|
||||
Interval = 1000,
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
Timer countdown;
|
||||
|
||||
public VideoPlayer(string id, string channelAvatar)
|
||||
{
|
||||
@@ -83,14 +93,15 @@ namespace FoxTube
|
||||
|
||||
t.Elapsed += T_Elapsed;
|
||||
seekTimer.Elapsed += SeekTimer_Elapsed;
|
||||
CheckQualityAvailability(id);
|
||||
Initialize(id, channelAvatar);
|
||||
}
|
||||
|
||||
public async void Initialize(string id, string channelAvatar)
|
||||
{
|
||||
CheckQualityAvailability(id);
|
||||
|
||||
videoId = id;
|
||||
VideosResource.ListRequest request = SecretsVault.YoutubeService.Videos.List("snippet,contentDetails,statistics");
|
||||
VideosResource.ListRequest request = SecretsVault.YoutubeService.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
|
||||
request.Id = id;
|
||||
|
||||
VideoListResponse response = await request.ExecuteAsync();
|
||||
@@ -116,9 +127,38 @@ namespace FoxTube
|
||||
touchCentral.Visibility = Visibility.Collapsed;
|
||||
miniView.Visibility = Visibility.Collapsed;
|
||||
controls.Visibility = Visibility.Visible;
|
||||
|
||||
schedulePanel.Visibility = Visibility.Visible;
|
||||
if (item.LiveStreamingDetails.ScheduledStartTime != null)
|
||||
{
|
||||
scheduleStart.Text = "Start time: " + item.LiveStreamingDetails.ScheduledStartTime;
|
||||
|
||||
countdown = new Timer()
|
||||
{
|
||||
Interval = 1000,
|
||||
Enabled = true
|
||||
};
|
||||
countdown.Elapsed += Countdown_Elapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
scheduleHeader.Visibility = Visibility.Collapsed;
|
||||
scheduleStart.Visibility = Visibility.Collapsed;
|
||||
|
||||
countdownHeader.Visibility = Visibility.Collapsed;
|
||||
streamCountdown.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
if (item.LiveStreamingDetails.ScheduledEndTime != null)
|
||||
scheduleEnd.Text = "End time: " + item.LiveStreamingDetails.ScheduledEndTime;
|
||||
else scheduleEnd.Visibility = Visibility.Collapsed;
|
||||
try { videoSource.PosterSource = new BitmapImage(new Uri(item.Snippet.Thumbnails.Maxres.Url)); }
|
||||
catch { }
|
||||
title.Text = item.Snippet.Title;
|
||||
return;
|
||||
}
|
||||
|
||||
videoSource.PosterSource = new BitmapImage(new Uri(item.Snippet.Thumbnails.Maxres.Url));
|
||||
try { videoSource.PosterSource = new BitmapImage(new Uri(item.Snippet.Thumbnails.Maxres.Url)); }
|
||||
catch { }
|
||||
title.Text = item.Snippet.Title;
|
||||
|
||||
YouTubeUri uri = await YouTube.GetVideoUriAsync(id, qualities[quality.SelectedIndex]);
|
||||
@@ -132,9 +172,7 @@ namespace FoxTube
|
||||
|
||||
elapsedTime.Text = string.Format("{0}{1:00}:{2:00}", elapsed.Hours == 0 ? "" : elapsed.Hours + ":", elapsed.Minutes, elapsed.Seconds);
|
||||
remainingTime.Text = string.Format("{0}{1:00}:{2:00}", remaining.Hours == 0 ? "" : remaining.Hours + ":", remaining.Minutes, remaining.Seconds);
|
||||
|
||||
|
||||
|
||||
|
||||
systemControls.IsNextEnabled = true;
|
||||
systemControls.IsPauseEnabled = true;
|
||||
systemControls.IsPlayEnabled = true;
|
||||
@@ -148,23 +186,41 @@ namespace FoxTube
|
||||
systemControls.ButtonPressed += SystemControls_Engaged;
|
||||
}
|
||||
|
||||
void CheckQualityAvailability(string id)
|
||||
private async void Countdown_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, CountdownElapsed);
|
||||
}
|
||||
|
||||
void CountdownElapsed()
|
||||
{
|
||||
TimeSpan span = (TimeSpan)(item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now);
|
||||
if (span.TotalMilliseconds > 0)
|
||||
streamCountdown.Text = string.Format("{0}{1:00}:{2:00}:{3:00}", span.Days != 0 ? span.Days + ":" : "", span.Hours, span.Minutes, span.Seconds);
|
||||
else
|
||||
{
|
||||
streamCountdown.Text = "Stream will be started shortly...";
|
||||
countdownHeader.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
async void CheckQualityAvailability(string id)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
YouTube.GetVideoUriAsync(id, qualities[i]);
|
||||
YouTubeUri uri = await YouTube.GetVideoUriAsync(id, qualities[i]);
|
||||
Debug.WriteLine(qualities[i].ToString() + ": Checked");
|
||||
Debug.WriteLine("Result URI: " + uri.Uri);
|
||||
}
|
||||
catch
|
||||
{
|
||||
(quality.Items[i] as ComboBoxItem).Visibility = Visibility.Collapsed;
|
||||
Debug.WriteLine(qualities[i].ToString() + ": Error");
|
||||
}
|
||||
}
|
||||
int k = (int)settings.Values["quality"] +
|
||||
(int)settings.Values["quality"] > 0 ? 1 : 0;
|
||||
|
||||
int k = (int)settings.Values["quality"];
|
||||
if ((quality.Items[k] as ComboBoxItem).Visibility == Visibility.Collapsed)
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 7; i >= 0; i--)
|
||||
{
|
||||
if ((quality.Items[i] as ComboBoxItem).Visibility == Visibility.Visible)
|
||||
{
|
||||
@@ -207,25 +263,28 @@ namespace FoxTube
|
||||
seek.Value = videoSource.Position.TotalSeconds;
|
||||
}
|
||||
|
||||
async void Elapsed()
|
||||
void Elapsed()
|
||||
{
|
||||
if(!volumePane.IsOpen && !qualityPane.IsOpen && item.Snippet.LiveBroadcastContent != "upcoming")
|
||||
{
|
||||
await controls.Fade().StartAsync();
|
||||
//await controls.Fade().StartAsync();
|
||||
volumePane.IsOpen = false;
|
||||
qualityPane.IsOpen = false;
|
||||
controls.Visibility = Visibility.Collapsed;
|
||||
if(!miniViewed)
|
||||
touchCentral.Visibility = Visibility.Collapsed;
|
||||
if (pointerCaptured)
|
||||
/*if (pointerCaptured)
|
||||
{
|
||||
cursorBackup = Window.Current.CoreWindow.PointerCursor;
|
||||
Window.Current.CoreWindow.PointerCursor = null;
|
||||
}*/
|
||||
t.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
Height = e.NewSize.Width / 16 * 9;
|
||||
//Height = e.NewSize.Width / 16 * 9;
|
||||
}
|
||||
|
||||
private void openVolume_Click(object sender, RoutedEventArgs e)
|
||||
@@ -249,7 +308,7 @@ namespace FoxTube
|
||||
|
||||
settings.Values["volume"] = volume.Value;
|
||||
|
||||
videoSource.Volume = volume.Value;
|
||||
videoSource.Volume = volume.Value * 0.01;
|
||||
}
|
||||
|
||||
private void openSets_Click(object sender, RoutedEventArgs e)
|
||||
@@ -297,8 +356,10 @@ namespace FoxTube
|
||||
if(controls.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
controls.Visibility = Visibility.Visible;
|
||||
await controls.Fade(value: 1).StartAsync();
|
||||
//await controls.Fade(value: 1).StartAsync();
|
||||
}
|
||||
/*if (pointerCaptured)
|
||||
Window.Current.CoreWindow.PointerCursor = cursorBackup;*/
|
||||
t.Stop();
|
||||
t.Start();
|
||||
}
|
||||
@@ -325,21 +386,23 @@ namespace FoxTube
|
||||
|
||||
private void fullscreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TimeSpan elapsedBakcup = new TimeSpan(videoSource.Position.Ticks);
|
||||
if (fullScreen)
|
||||
{
|
||||
Window.Current.Content = rootBackup;
|
||||
//SecretsVault.SubLayer.ExitFullScreen();
|
||||
SetFullSize.Invoke(this, null);
|
||||
ApplicationView.GetForCurrentView().ExitFullScreenMode();
|
||||
fullscreen.Content = "";
|
||||
fullScreen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootBackup = Window.Current.Content;
|
||||
Window.Current.Content = this;
|
||||
//SecretsVault.SubLayer.EnterFullScreen(this);
|
||||
fullScreen = ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
|
||||
}
|
||||
if ((string)fullscreen.Content == "")
|
||||
SetFullSize.Invoke(this, null);
|
||||
fullscreen.Content = "";
|
||||
else fullscreen.Content = "";
|
||||
}
|
||||
videoSource.Position = elapsedBakcup;
|
||||
}
|
||||
|
||||
private void play_Click(object sender, RoutedEventArgs e)
|
||||
@@ -356,28 +419,39 @@ namespace FoxTube
|
||||
{
|
||||
case MediaElementState.Buffering:
|
||||
bufferingBar.Visibility = Visibility.Visible;
|
||||
|
||||
seek.IsEnabled = false;
|
||||
play.IsEnabled = false;
|
||||
seekTimer.Stop();
|
||||
touchPlay.IsEnabled = false;
|
||||
|
||||
play.Content = "";
|
||||
touchPlay.Content = "";
|
||||
break;
|
||||
|
||||
case MediaElementState.Paused:
|
||||
bufferingBar.Visibility = Visibility.Collapsed;
|
||||
|
||||
seek.IsEnabled = true;
|
||||
play.IsEnabled = true;
|
||||
touchPlay.IsEnabled = true;
|
||||
|
||||
play.Content = "";
|
||||
touchPlay.Content = "";
|
||||
seekTimer.Stop();
|
||||
break;
|
||||
|
||||
case MediaElementState.Playing:
|
||||
bufferingBar.Visibility = Visibility.Collapsed;
|
||||
|
||||
seek.IsEnabled = true;
|
||||
play.IsEnabled = true;
|
||||
touchPlay.IsEnabled = true;
|
||||
|
||||
play.Content = "";
|
||||
touchPlay.Content = "";
|
||||
seekTimer.Start();
|
||||
break;
|
||||
|
||||
default:
|
||||
bufferingBar.Visibility = Visibility.Collapsed;
|
||||
seekTimer.Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -389,12 +463,15 @@ namespace FoxTube
|
||||
|
||||
private async void miniView_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(fullScreen)
|
||||
TimeSpan elapsedBakcup = new TimeSpan(videoSource.Position.Ticks);
|
||||
if (fullScreen)
|
||||
{
|
||||
ApplicationView.GetForCurrentView().ExitFullScreenMode();
|
||||
fullScreen = false;
|
||||
fullscreen.Content = "";
|
||||
fullScreen = false;
|
||||
}
|
||||
else
|
||||
SetFullSize.Invoke(this, null);
|
||||
|
||||
if (!miniViewed)
|
||||
{
|
||||
@@ -405,7 +482,6 @@ namespace FoxTube
|
||||
header.Visibility = Visibility.Collapsed;
|
||||
touchBack10.FontSize = touchFwd30.FontSize = 20;
|
||||
touchPlay.FontSize = 50;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -417,6 +493,7 @@ namespace FoxTube
|
||||
touchBack10.FontSize = touchFwd30.FontSize = 40;
|
||||
touchPlay.FontSize = 100;
|
||||
}
|
||||
videoSource.Position = elapsedBakcup;
|
||||
}
|
||||
|
||||
private void seek_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
||||
@@ -457,5 +534,10 @@ namespace FoxTube
|
||||
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
|
||||
pointerCaptured = true;
|
||||
}
|
||||
|
||||
private void next_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NextClicked.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user