Archived
1
0

Video page rebuild

Channel playlist tab more button fixed
This commit is contained in:
Michael Gordeev
2018-08-02 22:59:35 +03:00
parent ee96d7b75e
commit 114384b3eb
14 changed files with 237 additions and 442 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ namespace FoxTube.Controls
public sealed partial class ChannelCard : UserControl public sealed partial class ChannelCard : UserControl
{ {
string channelId; string channelId;
Google.Apis.YouTube.v3.Data.Channel item; Channel item;
public ChannelCard(string id, string live = "null") public ChannelCard(string id, string live = "null")
{ {
+2 -3
View File
@@ -91,10 +91,9 @@
Content="" /> Content="" />
<ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/> <ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/>
<StackPanel Grid.Row="2"> <StackPanel Grid.Row="2" Name="repliesPlaceholder">
<StackPanel Margin="60,0,0,0" Name="replies"/> <StackPanel Margin="60,0,0,0" Name="replies"/>
<HyperlinkButton Visibility="Collapsed" HorizontalAlignment="Center" Name="more" Click="more_Click" Foreground="Red" Content="Show more replies"/> <local:ShowMore Clicked="more_Click"/>
<ProgressBar IsIndeterminate="True" Foreground="Red" Name="moreLoading" Visibility="Collapsed"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>
+20 -23
View File
@@ -26,6 +26,8 @@ namespace FoxTube.Controls
public enum CommentType { TopLevel, Reply } public enum CommentType { TopLevel, Reply }
public sealed partial class CommentCard : UserControl public sealed partial class CommentCard : UserControl
{ {
ShowMore more;
Comment item; Comment item;
CommentThread thread; CommentThread thread;
CommentType type = CommentType.TopLevel; CommentType type = CommentType.TopLevel;
@@ -34,6 +36,7 @@ namespace FoxTube.Controls
public CommentCard(CommentThread comment) public CommentCard(CommentThread comment)
{ {
this.InitializeComponent(); this.InitializeComponent();
more = repliesPlaceholder.Children[1] as ShowMore;
Initialize(comment); Initialize(comment);
} }
@@ -65,26 +68,21 @@ namespace FoxTube.Controls
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.TopLevelComment.Snippet.AuthorProfileImageUrl)); } try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.TopLevelComment.Snippet.AuthorProfileImageUrl)); }
catch { } catch { }
if (comment.Replies != null && comment.Replies.Comments.Count > 0) if(comment.Snippet.TotalReplyCount > 0)
{ {
if (comment.Replies.Comments.Count <= 5) var request = SecretsVault.Service.Comments.List("snippet");
foreach (Comment reply in comment.Replies.Comments) request.ParentId = item.Id;
replies.Children.Add(new CommentCard(reply)); request.MaxResults = 10;
var response = await request.ExecuteAsync();
if (response.NextPageToken != null)
NextPageToken = response.NextPageToken;
else else
{ more.Visibility = Visibility.Collapsed;
var request = SecretsVault.NoAuthService.Comments.List("snippet");
request.ParentId = item.Id;
var response = await request.ExecuteAsync();
if(response.NextPageToken != null) foreach (Comment c in response.Items)
{ replies.Children.Add(new CommentCard(c));
NextPageToken = response.NextPageToken;
more.Visibility = Visibility.Visible;
}
foreach (Comment c in response.Items)
replies.Children.Add(new CommentCard(c));
}
} }
} }
@@ -139,13 +137,11 @@ namespace FoxTube.Controls
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]); Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
} }
private async void more_Click(object sender, RoutedEventArgs e) private async void more_Click()
{ {
more.Visibility = Visibility.Collapsed;
moreLoading.Visibility = Visibility.Visible;
var request = SecretsVault.NoAuthService.Comments.List("snippet"); var request = SecretsVault.NoAuthService.Comments.List("snippet");
request.ParentId = item.Id; request.ParentId = item.Id;
request.MaxResults = 10;
request.PageToken = NextPageToken; request.PageToken = NextPageToken;
var response = await request.ExecuteAsync(); var response = await request.ExecuteAsync();
@@ -155,9 +151,10 @@ namespace FoxTube.Controls
if (response.NextPageToken != null) if (response.NextPageToken != null)
{ {
NextPageToken = response.NextPageToken; NextPageToken = response.NextPageToken;
more.Visibility = Visibility.Visible; more.Complete();
} }
moreLoading.Visibility = Visibility.Collapsed; else
more.Complete(true);
} }
private void reply_TextChanged(object sender, TextChangedEventArgs e) private void reply_TextChanged(object sender, TextChangedEventArgs e)
+1 -2
View File
@@ -85,7 +85,7 @@ namespace FoxTube
Timer countdown; Timer countdown;
public VideoPlayer(Google.Apis.YouTube.v3.Data.Video meta, string channelAvatar) public VideoPlayer()
{ {
this.InitializeComponent(); this.InitializeComponent();
if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
@@ -102,7 +102,6 @@ namespace FoxTube
t.Elapsed += T_Elapsed; t.Elapsed += T_Elapsed;
seekTimer.Elapsed += SeekTimer_Elapsed; seekTimer.Elapsed += SeekTimer_Elapsed;
Initialize(meta, channelAvatar);
} }
public async void Initialize(Google.Apis.YouTube.v3.Data.Video meta, string channelAvatar) public async void Initialize(Google.Apis.YouTube.v3.Data.Video meta, string channelAvatar)
+3 -10
View File
@@ -168,14 +168,11 @@
<Compile Include="Pages\Settings.xaml.cs"> <Compile Include="Pages\Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon> <DependentUpon>Settings.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="SubLayer.xaml.cs">
<DependentUpon>SubLayer.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\SettingsPages\Translate.xaml.cs"> <Compile Include="Pages\SettingsPages\Translate.xaml.cs">
<DependentUpon>Translate.xaml</DependentUpon> <DependentUpon>Translate.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Pages\Video.xaml.cs"> <Compile Include="Pages\VideoPage.xaml.cs">
<DependentUpon>Video.xaml</DependentUpon> <DependentUpon>VideoPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\VideoCard.xaml.cs"> <Compile Include="Controls\VideoCard.xaml.cs">
<DependentUpon>VideoCard.xaml</DependentUpon> <DependentUpon>VideoCard.xaml</DependentUpon>
@@ -366,15 +363,11 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="SubLayer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\SettingsPages\Translate.xaml"> <Page Include="Pages\SettingsPages\Translate.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Pages\Video.xaml"> <Page Include="Pages\VideoPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
+2 -2
View File
@@ -102,7 +102,7 @@ namespace FoxTube.Pages
} }
catch { } catch { }
description.Text = item.Snippet.Description; Methods.FormatText(ref description, item.Snippet.Description);
views.Text = $"{item.Statistics.ViewCount:0,0}"; views.Text = $"{item.Statistics.ViewCount:0,0}";
registration.Text = item.Snippet.PublishedAt.ToString(); registration.Text = item.Snippet.PublishedAt.ToString();
@@ -171,7 +171,7 @@ namespace FoxTube.Pages
if (!string.IsNullOrWhiteSpace(response.NextPageToken)) if (!string.IsNullOrWhiteSpace(response.NextPageToken))
playlistToken = response.NextPageToken; playlistToken = response.NextPageToken;
else else
playlistMore.Complete(true); playlistMore.Visibility = Visibility.Collapsed;
playlistLoading.Close(); playlistLoading.Close();
} }
+5 -5
View File
@@ -37,7 +37,7 @@ namespace FoxTube.Pages
this.InitializeComponent(); this.InitializeComponent();
} }
public async void Initialize(Google.Apis.YouTube.v3.Data.Video video) public async void Initialize(Video video)
{ {
threadId = video.Id; threadId = video.Id;
@@ -46,7 +46,7 @@ namespace FoxTube.Pages
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount); counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies"); var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order; request.Order = order;
request.VideoId = video.Id; request.VideoId = video.Id;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText; request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -67,7 +67,7 @@ namespace FoxTube.Pages
more.Visibility = Visibility.Collapsed; more.Visibility = Visibility.Collapsed;
moreLoading.Visibility = Visibility.Visible; moreLoading.Visibility = Visibility.Visible;
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies"); var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order; request.Order = order;
request.VideoId = threadId; request.VideoId = threadId;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText; request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -97,7 +97,7 @@ namespace FoxTube.Pages
placeholder.Children.Clear(); placeholder.Children.Clear();
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies"); var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order; request.Order = order;
request.VideoId = threadId; request.VideoId = threadId;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText; request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -124,7 +124,7 @@ namespace FoxTube.Pages
placeholder.Children.Clear(); placeholder.Children.Clear();
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies"); var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order; request.Order = order;
request.VideoId = threadId; request.VideoId = threadId;
var response = await request.ExecuteAsync(); var response = await request.ExecuteAsync();
+2 -2
View File
@@ -440,7 +440,7 @@ namespace FoxTube
videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch; videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
videoPlaceholder.Margin = new Thickness(0); videoPlaceholder.Margin = new Thickness(0);
videoPlaceholder.Navigate(typeof(Video), id); videoPlaceholder.Navigate(typeof(VideoPage), id);
} }
public void GoToDeveloper(string id) public void GoToDeveloper(string id)
@@ -458,7 +458,7 @@ namespace FoxTube
private void Page_SizeChanged(object sender, SizeChangedEventArgs e) private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
(videoPlaceholder.Content as Video).player.UpdateSize(); (videoPlaceholder.Content as VideoPage).player.UpdateSize();
if(isForcedCollapsed) if(isForcedCollapsed)
{ {
+1 -1
View File
@@ -50,7 +50,7 @@ namespace FoxTube.Pages
{ {
base.OnNavigatedTo(e); base.OnNavigatedTo(e);
if (e.Parameter == null) if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated."); loading.Error("NullReferenceException", "Unable to initialize page. Playlist ID is not stated.");
else else
Initialize(e.Parameter as string); Initialize(e.Parameter as string);
} }
-154
View File
@@ -1,154 +0,0 @@
<Page
x:Class="FoxTube.Video"
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"
xmlns:pages="using:FoxTube.Pages"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d">
<Grid Name="mainGrid">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions>
<ScrollViewer Margin="0,0,0,50" Name="mainScroll">
<StackPanel Orientation="Vertical" Name="mainContent">
<StackPanel Name="playerPlaceholder"/>
<StackPanel Margin="10" Name="descriptionPanel">
<TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/>
<Grid>
<Button Padding="0" Background="Transparent" Margin="5" Name="gotoChannel" Click="gotoChannel_Click">
<StackPanel Orientation="Horizontal">
<PersonPicture Name="channelAvatar" Width="90"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="5" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
</StackPanel>
<TextBlock Name="subscribers" Text="[subscribers]" Foreground="Gray"/>
<StackPanel Name="subscribePanel" Orientation="Horizontal" Margin="0,5,0,0">
<ToggleButton Grid.Column="2" Height="30" Width="150" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe"/>
<ToggleButton Grid.Column="3" Height="30" Width="30" Padding="0" FontFamily="Segoe MDL2 Assets" FontSize="14" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Button>
<StackPanel HorizontalAlignment="Right">
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
<ProgressBar Name="rating" Width="250" Background="Green" Foreground="Red"/>
<Grid>
<FontIcon Foreground="Gray"
HorizontalAlignment="Left"
FontSize="40"
Name="dislike" Tapped="dislike_Click"
Glyph="&#xE19E;"/>
<FontIcon Foreground="Gray"
HorizontalAlignment="Right"
FontSize="40"
Name="like" Tapped="like_Click"
Glyph="&#xE19F;"/>
</Grid>
<Grid>
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
<TextBlock HorizontalAlignment="Right" Foreground="Gray" Text="[likes]" Name="likes"/>
</Grid>
</StackPanel>
</Grid>
<TextBlock Name="description" Text="[Description]" IsTextSelectionEnabled="True" TextWrapping="WrapWholeWords"/>
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Published at: "/>
<TextBlock Grid.Row="1" Text="Category: "/>
<TextBlock Grid.Row="2" Text="License: "/>
<TextBlock Name="publishedAt" Grid.Column="2" Text="[Publishing date]"/>
<TextBlock Name="category" Grid.Column="2" Grid.Row="1" Padding="0" Text="[Category]"/>
<TextBlock Name="license" Grid.Column="2" Grid.Row="2" Text="[License type]"/>
</Grid>
</StackPanel>
</StackPanel>
</ScrollViewer>
<CommandBar VerticalAlignment="Bottom" Name="commandbar">
<AppBarButton Name="download" Icon="Download" Label="Download video">
<AppBarButton.Flyout>
<MenuFlyout x:Name="downloadSelector">
<MenuFlyoutItem Text="Select quality:" IsEnabled="False"/>
<MenuFlyoutSeparator/>
<MenuFlyoutItem Text="No items are available" IsEnabled="False"/>
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarToggleButton Name="addLater" Click="addLater_Click" Icon="Clock" Label="Watch later" Visibility="Collapsed"/>
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
<CommandBar.SecondaryCommands>
<AppBarButton Name="addToPlaylist" Click="addToPlaylist_Click" Icon="Add" Label="Add to playlist" Visibility="Collapsed">
<AppBarButton.Flyout>
<MenuFlyout>
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton Icon="Flag" Label="Report this video" Visibility="Collapsed"/>
</CommandBar.SecondaryCommands>
</CommandBar>
<Grid Grid.Column="1" Name="tabsPlaceholder">
<Grid Name="tabs">
<Grid.RowDefinitions>
<RowDefinition Height="47"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Background="Red">
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<HyperlinkButton Name="toDescription" Click="toDescription_Click" Foreground="White" Margin="0,0,10,0" Visibility="Collapsed">
<TextBlock Text="Description"/>
</HyperlinkButton>
<HyperlinkButton Name="toPlaylist" Click="toPlaylist_Click" Foreground="White" Margin="0,0,10,0" Visibility="Collapsed">
<TextBlock Text="Playlist"/>
</HyperlinkButton>
<HyperlinkButton Name="toSuggestions" Click="toSuggestions_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Suggestions"/>
</HyperlinkButton>
<HyperlinkButton Name="toComments" Click="toComments_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Comments"/>
</HyperlinkButton>
</StackPanel>
</Grid>
<Pivot Grid.Row="1" Name="pivot" SelectedIndex="0" SelectionChanged="pivot_SelectionChanged">
<PivotItem Margin="0,-48,0,0">
<Grid Name="relatedGrid">
<ScrollViewer>
<StackPanel Name="relatedVideos"/>
</ScrollViewer>
</Grid>
</PivotItem>
<PivotItem Margin="0,-48,0,0" Name="commentsPlaceholder">
<pages:CommentsPage/>
</PivotItem>
</Pivot>
</Grid>
</Grid>
</Grid>
</Grid>
</Page>
+141
View File
@@ -0,0 +1,141 @@
<Page
x:Class="FoxTube.Pages.VideoPage"
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"
xmlns:pages="using:FoxTube.Pages"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:ui="using:Microsoft.Advertising.WinRT.UI"
mc:Ignorable="d">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions>
<ScrollViewer Margin="0,0,0,50" Name="mainScroll">
<StackPanel Orientation="Vertical" Name="mainContent">
<local:VideoPlayer/>
<StackPanel Margin="10" Name="descriptionPanel">
<TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/>
<Grid>
<Button Padding="0" Background="Transparent" Margin="5" Name="gotoChannel" Click="gotoChannel_Click">
<StackPanel Orientation="Horizontal">
<PersonPicture Name="channelAvatar" Width="90"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="5" VerticalAlignment="Center">
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
<TextBlock Name="subscribers" Text="[subscribers]" Foreground="Gray" Margin="0,0,0,5"/>
<ToggleButton Grid.Column="2" Height="30" Width="200" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe" Name="subscribe"/>
</StackPanel>
</StackPanel>
</Button>
<StackPanel HorizontalAlignment="Right">
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
<ProgressBar Name="rating" Width="250" Background="Green" Foreground="Red"/>
<Grid>
<FontIcon Foreground="Gray"
HorizontalAlignment="Left"
FontSize="40"
Name="dislike" Tapped="dislike_Click"
Glyph="&#xE19E;"/>
<FontIcon Foreground="Gray"
HorizontalAlignment="Right"
FontSize="40"
Name="like" Tapped="like_Click"
Glyph="&#xE19F;"/>
</Grid>
<Grid>
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
<TextBlock HorizontalAlignment="Right" Foreground="Gray" Text="[likes]" Name="likes"/>
</Grid>
</StackPanel>
</Grid>
<TextBlock Name="description" Text="[Description]" IsTextSelectionEnabled="True" TextWrapping="WrapWholeWords"/>
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Published at: "/>
<TextBlock Grid.Row="1" Text="Category: "/>
<TextBlock Grid.Row="2" Text="License: "/>
<TextBlock Name="publishedAt" Grid.Column="2" Text="[Publishing date]"/>
<TextBlock Name="category" Grid.Column="2" Grid.Row="1" Padding="0" Text="[Category]"/>
<TextBlock Name="license" Grid.Column="2" Grid.Row="2" Text="[License type]"/>
</Grid>
</StackPanel>
</StackPanel>
</ScrollViewer>
<CommandBar VerticalAlignment="Bottom" Name="commandbar">
<AppBarButton Icon="Download" Label="Download video" Name="download">
<AppBarButton.Flyout>
<MenuFlyout x:Name="downloadSelector">
<MenuFlyoutItem Text="No items are available" IsEnabled="False"/>
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton Label="Add to" Icon="Add" IsEnabled="False"/>
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
</CommandBar>
<Grid Grid.Column="1" Name="tabsPlaceholder">
<Grid Name="tabs">
<Grid.RowDefinitions>
<RowDefinition Height="47"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Background="Red">
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<HyperlinkButton Name="toDescription" Click="toDescription_Click" Foreground="White" Margin="0,0,10,0" Visibility="Collapsed">
<TextBlock Text="Description"/>
</HyperlinkButton>
<HyperlinkButton Name="toPlaylist" Click="toPlaylist_Click" Foreground="White" Margin="0,0,10,0" Visibility="Collapsed">
<TextBlock Text="Playlist"/>
</HyperlinkButton>
<HyperlinkButton Name="toSuggestions" Click="toSuggestions_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Suggestions"/>
</HyperlinkButton>
<HyperlinkButton Name="toComments" Click="toComments_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Comments"/>
</HyperlinkButton>
</StackPanel>
</Grid>
<Pivot Grid.Row="1" Name="pivot" SelectedIndex="0" SelectionChanged="pivot_SelectionChanged">
<PivotItem Margin="0,-48,0,0">
<ScrollViewer>
<StackPanel>
<ui:AdControl
ApplicationId="3f83fe91-d6be-434d-a0ae-7351c5a997f1"
AdUnitId="test"
Width="320" Height="50"/>
<StackPanel Name="relatedVideos"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Margin="0,-48,0,0" Name="commentsPlaceholder">
<pages:CommentsPage/>
</PivotItem>
</Pivot>
</Grid>
</Grid>
<local:LoadingPage Grid.ColumnSpan="2" Visibility="Collapsed"/>
</Grid>
</Page>
@@ -35,41 +35,39 @@ using FoxTube.Controls;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube namespace FoxTube.Pages
{ {
public enum Rating { None, Like, Dislike } public enum Rating { None, Like, Dislike }
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// An empty page that can be used on its own or navigated to within a Frame.
/// </summary> /// </summary>
public sealed partial class Video : Page public sealed partial class VideoPage : Page
{ {
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
string videoId; string videoId;
Google.Apis.YouTube.v3.Data.Video item; Video item;
List<string> downloads = new List<string>(); List<string> downloads = new List<string>();
bool wide; bool wide;
bool isExtended = false; bool isExtended = false;
bool isAddedToLater = false;
Rating userRating = Rating.None; Rating userRating = Rating.None;
public VideoPlayer player; public VideoPlayer player;
public CommentsPage comments; public CommentsPage comments;
LoadingPage LoadingScreen = new LoadingPage(); LoadingPage loading;
LoadingPage loadingRelated = new LoadingPage();
System.Timers.Timer streamUpdateTimer; public VideoPage()
public Video()
{ {
this.InitializeComponent(); this.InitializeComponent();
mainGrid.Children.Add(LoadingScreen); loading = grid.Children[3] as LoadingPage;
relatedGrid.Children.Add(loadingRelated); loading.RefreshPage += refresh_Click;
LoadingScreen.RefreshPage += LoadingScreen_RefreshPage; player = mainContent.Children[0] as VideoPlayer;
player.SetFullSize += Player_SetFullSize;
comments = commentsPlaceholder.Content as CommentsPage;
DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share); DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share);
@@ -90,71 +88,47 @@ namespace FoxTube
grid.ColumnDefinitions[1].Width = new GridLength(0); grid.ColumnDefinitions[1].Width = new GridLength(0);
pivot.SelectedIndex = 0; pivot.SelectedIndex = 0;
pivot_SelectionChanged(this, null);
} }
} }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize page. Video ID is not stated.");
else
Initialize(e.Parameter as string);
}
public async void Initialize(string id) public async void Initialize(string id)
{ {
loading.Refresh();
try try
{ {
grid.Visibility = Visibility.Collapsed;
LoadingScreen.Refresh();
LoadingScreen.Visibility = Visibility.Visible;
videoId = id; videoId = id;
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet,contentDetails,statistics,status,liveStreamingDetails"); VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,statistics,status,contentDetails");
request.Id = id; request.Id = id;
item = (await request.ExecuteAsync()).Items[0];
VideoListResponse response = await request.ExecuteAsync(); title.Text = item.Snippet.Title;
item = response.Items[0]; Methods.FormatText(ref description, item.Snippet.Description);
if (item.Snippet.LiveBroadcastContent == "live")
{
views.Text = string.Format("{0:0,0} viewers", item.LiveStreamingDetails.ConcurrentViewers);
streamUpdateTimer = new System.Timers.Timer(10000);
streamUpdateTimer.Elapsed += StreamUpdateTimer_Elapsed;
toComments.Visibility = Visibility.Collapsed;
pivot.Items.RemoveAt(pivot.Items.Count - 1);
//(toComments.Content as TextBlock).Text = "Chat";
}
else
{
views.Text = string.Format("{0:0,0} views", item.Statistics.ViewCount);
comments = new CommentsPage();
commentsPlaceholder.Content = null;
commentsPlaceholder.Content = comments;
comments.Initialize(item);
}
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
categoryRequest.Id = item.Snippet.CategoryId;
VideoCategoryListResponse categoryResponse = await categoryRequest.ExecuteAsync();
VideoCategory cat = categoryResponse.Items[0];
category.Text = cat.Snippet.Title;
publishedAt.Text = item.Snippet.PublishedAt.ToString();
if (item.Status.License == "youtube") if (item.Status.License == "youtube")
license.Text = "Standard YouTube License"; license.Text = "Standard YouTube License";
else license.Text = "Creative Commons Attribution license (reuse allowed)"; else license.Text = "Creative Commons Attribution license (reuse allowed)";
publishedAt.Text = item.Snippet.PublishedAt.Value.ToString("d, MMMM, yyyy"); VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
title.Text = item.Snippet.Title; categoryRequest.Id = item.Snippet.CategoryId;
dislikes.Text = item.Statistics.DislikeCount.ToString(); category.Text = (await categoryRequest.ExecuteAsync()).Items[0].Snippet.Title;
likes.Text = item.Statistics.LikeCount.ToString();
views.Text = $"{item.Statistics.ViewCount:0,0} views";
dislikes.Text = $"{item.Statistics.DislikeCount:0,0}";
likes.Text = $"{item.Statistics.LikeCount:0,0}";
rating.Value = (double)item.Statistics.DislikeCount / (double)(item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100; rating.Value = (double)item.Statistics.DislikeCount / (double)(item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100;
Methods.FormatText(ref description, item.Snippet.Description);
ChannelsResource.ListRequest request1 = SecretsVault.NoAuthService.Channels.List("snippet,contentDetails,statistics"); if (SecretsVault.IsAuthorized)
request1.Id = item.Snippet.ChannelId;
ChannelListResponse response1 = await request1.ExecuteAsync();
var item1 = response1.Items[0];
channelAvatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
channelName.Text = item.Snippet.ChannelTitle;
subscribers.Text = string.Format("{0:0,0} subscribers", item1.Statistics.SubscriberCount);
if(SecretsVault.IsAuthorized)
{ {
VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(id).ExecuteAsync(); VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(id).ExecuteAsync();
if (ratingResponse.Items[0].Rating == "like") if (ratingResponse.Items[0].Rating == "like")
@@ -168,55 +142,40 @@ namespace FoxTube
dislike.Foreground = new SolidColorBrush(Colors.Red); dislike.Foreground = new SolidColorBrush(Colors.Red);
} }
/*addLater.Visibility = Visibility.Visible; foreach (Subscription s in SecretsVault.Subscriptions)
addToPlaylist.Visibility = Visibility.Visible;
if (SecretsVault.WatchLater.Contains(item.Id))
{ {
isAddedToLater = true; if (s.Snippet.ResourceId.ChannelId == item.Snippet.ChannelId)
addLater.IsChecked = true; {
}*/ subscribe.IsChecked = true;
subscribe.Content = "Subscribed";
}
}
subscribe.Visibility = Visibility.Visible;
} }
player = new VideoPlayer(item, item1.Snippet.Thumbnails.Medium.Url); ChannelsResource.ListRequest channelRequest = SecretsVault.Service.Channels.List("snippet, statistics");
player.SetFullSize += Player_SetFullSize; channelRequest.Id = item.Snippet.ChannelId;
var item1 = (await channelRequest.ExecuteAsync()).Items[0];
playerPlaceholder.Children.Add(player); channelAvatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
channelName.Text = item.Snippet.ChannelTitle;
subscribers.Text = $"{item1.Statistics.SubscriberCount:0,0} subscribers";
comments.Initialize(item);
player.Initialize(item, item1.Snippet.Thumbnails.Medium.Url);
LoadRelatedVideos();
LoadDownloads(); LoadDownloads();
Thread.Sleep(1000); loading.Close();
grid.Visibility = Visibility.Visible;
LoadingScreen.Visibility = Visibility.Collapsed;
LoadRelatedVideos();
/*if (SecretsVault.IsAuthorized && SecretsVault.UserHistory[0] != item.Id)
{
await SecretsVault.Service.PlaylistItems.Insert(new PlaylistItem()
{
Snippet = new PlaylistItemSnippet()
{
ResourceId = new ResourceId()
{
Kind = "youtube#video",
VideoId = item.Id
},
PlaylistId = SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchHistory
}
}, "snippet").ExecuteAsync();
SecretsVault.UserHistory.Insert(0, item.Id);
}*/
} }
catch catch
{ {
LoadingScreen.Error(); loading.Error();
} }
} }
async void LoadDownloads() async void LoadDownloads()
{ {
Debug.WriteLine("Loading download options...");
downloadSelector.Items.Clear(); downloadSelector.Items.Clear();
YouTubeUri[] uris = await YouTube.GetUrisAsync(item.Id); YouTubeUri[] uris = await YouTube.GetUrisAsync(item.Id);
@@ -239,14 +198,13 @@ namespace FoxTube
MenuFlyoutItem menuItem = new MenuFlyoutItem() MenuFlyoutItem menuItem = new MenuFlyoutItem()
{ {
Text = Methods.QualityToString(u.AudioQuality) Text = Methods.QualityToString(u.AudioQuality)
}; };
menuItem.Click += downloadItemSelected; menuItem.Click += downloadItemSelected;
downloadSelector.Items.Add(menuItem); downloadSelector.Items.Add(menuItem);
} }
} }
else else
download.Visibility = Visibility.Collapsed; download.Visibility = Visibility.Collapsed;
Debug.WriteLine("Done");
} }
private void downloadItemSelected(object sender, RoutedEventArgs e) private void downloadItemSelected(object sender, RoutedEventArgs e)
@@ -256,10 +214,7 @@ namespace FoxTube
async void LoadRelatedVideos() async void LoadRelatedVideos()
{ {
loadingRelated.Refresh(); SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
loadingRelated.Visibility = Visibility.Visible;
SearchResource.ListRequest request = SecretsVault.IsAuthorized? SecretsVault.Service.Search.List("snippet") : SecretsVault.NoAuthService.Search.List("snippet");
request.RelatedToVideoId = videoId; request.RelatedToVideoId = videoId;
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"]; request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
request.MaxResults = 20; request.MaxResults = 20;
@@ -269,32 +224,6 @@ namespace FoxTube
foreach (SearchResult video in response.Items) foreach (SearchResult video in response.Items)
relatedVideos.Children.Add(new VideoCard(video.Id.VideoId)); relatedVideos.Children.Add(new VideoCard(video.Id.VideoId));
loadingRelated.Visibility = Visibility.Collapsed;
}
private async void StreamUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, UpdateStreamDetails);
}
async void UpdateStreamDetails()
{
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("statistics,liveStreamingDetails");
request.Id = videoId;
VideoListResponse response = await request.ExecuteAsync();
var itemTemp = response.Items[0];
if (itemTemp.Snippet.LiveBroadcastContent == "live")
{
views.Text = itemTemp.LiveStreamingDetails.ConcurrentViewers + " viewers";
dislikes.Text = itemTemp.Statistics.DislikeCount.ToString();
likes.Text = itemTemp.Statistics.LikeCount.ToString();
rating.Value = (double)itemTemp.Statistics.DislikeCount / (double)(itemTemp.Statistics.DislikeCount + itemTemp.Statistics.LikeCount) * 100;
}
else streamUpdateTimer.Stop();
} }
private void Player_SetFullSize(object sender, EventArgs e) private void Player_SetFullSize(object sender, EventArgs e)
@@ -330,7 +259,7 @@ namespace FoxTube
private void gotoChannel_Click(object sender, RoutedEventArgs e) private void gotoChannel_Click(object sender, RoutedEventArgs e)
{ {
((Window.Current.Content as Frame).Content as MainPage).GoToChannel(item.Snippet.ChannelId); Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
} }
private async void openBrowser_Click(object sender, RoutedEventArgs e) private async void openBrowser_Click(object sender, RoutedEventArgs e)
@@ -339,22 +268,15 @@ namespace FoxTube
string timecode = player.elapsed.TotalSeconds > 10 ? string timecode = player.elapsed.TotalSeconds > 10 ?
"&t=" + (int)player.elapsed.TotalSeconds + "s" : string.Empty; "&t=" + (int)player.elapsed.TotalSeconds + "s" : string.Empty;
await Launcher.LaunchUriAsync(new Uri(string.Format("https://www.youtube.com/watch?v={0}{1}", videoId, timecode))); await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/watch?v={videoId}{timecode}"));
} }
private void refresh_Click(object sender, RoutedEventArgs e) private void refresh_Click(object sender, RoutedEventArgs e)
{ {
playerPlaceholder.Children.Clear(); player = new VideoPlayer();
player = null;
Initialize(videoId); Initialize(videoId);
} }
private void LoadingScreen_RefreshPage(object sender, RoutedEventArgs e)
{
refresh_Click(this, null);
}
private void grid_SizeChanged(object sender, SizeChangedEventArgs e) private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
if (e.NewSize.Width > 1000) if (e.NewSize.Width > 1000)
@@ -578,35 +500,5 @@ namespace FoxTube
break; break;
} }
} }
private async void addLater_Click(object sender, RoutedEventArgs e)
{
isAddedToLater = !isAddedToLater;
if(isAddedToLater)
{
PlaylistItem pi = await SecretsVault.Service.PlaylistItems.Insert(new PlaylistItem()
{
Snippet = new PlaylistItemSnippet()
{
ResourceId = new ResourceId()
{
Kind = "youtube#video",
VideoId = item.Id
},
PlaylistId = SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater
}
}, "snippet").ExecuteAsync();
SecretsVault.WatchLater.Insert(0, pi);
}
else
{
//await SecretsVault.Service.PlaylistItems.Delete(SecretsVault.WatchLater[])
}
}
private void addToPlaylist_Click(object sender, RoutedEventArgs e)
{
}
} }
} }
-12
View File
@@ -1,12 +0,0 @@
<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>
-60
View File
@@ -1,60 +0,0 @@
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;*/
}
}
}