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
+2 -2
View File
@@ -102,7 +102,7 @@ namespace FoxTube.Pages
}
catch { }
description.Text = item.Snippet.Description;
Methods.FormatText(ref description, item.Snippet.Description);
views.Text = $"{item.Statistics.ViewCount:0,0}";
registration.Text = item.Snippet.PublishedAt.ToString();
@@ -171,7 +171,7 @@ namespace FoxTube.Pages
if (!string.IsNullOrWhiteSpace(response.NextPageToken))
playlistToken = response.NextPageToken;
else
playlistMore.Complete(true);
playlistMore.Visibility = Visibility.Collapsed;
playlistLoading.Close();
}
+5 -5
View File
@@ -37,7 +37,7 @@ namespace FoxTube.Pages
this.InitializeComponent();
}
public async void Initialize(Google.Apis.YouTube.v3.Data.Video video)
public async void Initialize(Video video)
{
threadId = video.Id;
@@ -46,7 +46,7 @@ namespace FoxTube.Pages
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.VideoId = video.Id;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -67,7 +67,7 @@ namespace FoxTube.Pages
more.Visibility = Visibility.Collapsed;
moreLoading.Visibility = Visibility.Visible;
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order;
request.VideoId = threadId;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -97,7 +97,7 @@ namespace FoxTube.Pages
placeholder.Children.Clear();
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order;
request.VideoId = threadId;
request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
@@ -124,7 +124,7 @@ namespace FoxTube.Pages
placeholder.Children.Clear();
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
var request = SecretsVault.Service.CommentThreads.List("snippet,replies");
request.Order = order;
request.VideoId = threadId;
var response = await request.ExecuteAsync();
+2 -2
View File
@@ -440,7 +440,7 @@ namespace FoxTube
videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
videoPlaceholder.Margin = new Thickness(0);
videoPlaceholder.Navigate(typeof(Video), id);
videoPlaceholder.Navigate(typeof(VideoPage), id);
}
public void GoToDeveloper(string id)
@@ -458,7 +458,7 @@ namespace FoxTube
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (videoPlaceholder.Content != null)
(videoPlaceholder.Content as Video).player.UpdateSize();
(videoPlaceholder.Content as VideoPage).player.UpdateSize();
if(isForcedCollapsed)
{
+1 -1
View File
@@ -50,7 +50,7 @@ namespace FoxTube.Pages
{
base.OnNavigatedTo(e);
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
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
namespace FoxTube
namespace FoxTube.Pages
{
public enum Rating { None, Like, Dislike }
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Video : Page
public sealed partial class VideoPage : Page
{
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
string videoId;
Google.Apis.YouTube.v3.Data.Video item;
Video item;
List<string> downloads = new List<string>();
bool wide;
bool isExtended = false;
bool isAddedToLater = false;
Rating userRating = Rating.None;
public VideoPlayer player;
public CommentsPage comments;
LoadingPage LoadingScreen = new LoadingPage();
LoadingPage loadingRelated = new LoadingPage();
LoadingPage loading;
System.Timers.Timer streamUpdateTimer;
public Video()
public VideoPage()
{
this.InitializeComponent();
mainGrid.Children.Add(LoadingScreen);
relatedGrid.Children.Add(loadingRelated);
LoadingScreen.RefreshPage += LoadingScreen_RefreshPage;
loading = grid.Children[3] as LoadingPage;
loading.RefreshPage += refresh_Click;
player = mainContent.Children[0] as VideoPlayer;
player.SetFullSize += Player_SetFullSize;
comments = commentsPlaceholder.Content as CommentsPage;
DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share);
@@ -90,71 +88,47 @@ namespace FoxTube
grid.ColumnDefinitions[1].Width = new GridLength(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)
{
loading.Refresh();
try
{
grid.Visibility = Visibility.Collapsed;
LoadingScreen.Refresh();
LoadingScreen.Visibility = Visibility.Visible;
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;
item = (await request.ExecuteAsync()).Items[0];
VideoListResponse response = await request.ExecuteAsync();
item = response.Items[0];
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;
title.Text = item.Snippet.Title;
Methods.FormatText(ref description, item.Snippet.Description);
publishedAt.Text = item.Snippet.PublishedAt.ToString();
if (item.Status.License == "youtube")
license.Text = "Standard YouTube License";
else license.Text = "Creative Commons Attribution license (reuse allowed)";
publishedAt.Text = item.Snippet.PublishedAt.Value.ToString("d, MMMM, yyyy");
title.Text = item.Snippet.Title;
dislikes.Text = item.Statistics.DislikeCount.ToString();
likes.Text = item.Statistics.LikeCount.ToString();
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
categoryRequest.Id = item.Snippet.CategoryId;
category.Text = (await categoryRequest.ExecuteAsync()).Items[0].Snippet.Title;
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;
Methods.FormatText(ref description, item.Snippet.Description);
ChannelsResource.ListRequest request1 = SecretsVault.NoAuthService.Channels.List("snippet,contentDetails,statistics");
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)
if (SecretsVault.IsAuthorized)
{
VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(id).ExecuteAsync();
if (ratingResponse.Items[0].Rating == "like")
@@ -168,55 +142,40 @@ namespace FoxTube
dislike.Foreground = new SolidColorBrush(Colors.Red);
}
/*addLater.Visibility = Visibility.Visible;
addToPlaylist.Visibility = Visibility.Visible;
if (SecretsVault.WatchLater.Contains(item.Id))
foreach (Subscription s in SecretsVault.Subscriptions)
{
isAddedToLater = true;
addLater.IsChecked = true;
}*/
if (s.Snippet.ResourceId.ChannelId == item.Snippet.ChannelId)
{
subscribe.IsChecked = true;
subscribe.Content = "Subscribed";
}
}
subscribe.Visibility = Visibility.Visible;
}
player = new VideoPlayer(item, item1.Snippet.Thumbnails.Medium.Url);
player.SetFullSize += Player_SetFullSize;
ChannelsResource.ListRequest channelRequest = SecretsVault.Service.Channels.List("snippet, statistics");
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();
Thread.Sleep(1000);
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);
}*/
loading.Close();
}
catch
{
LoadingScreen.Error();
loading.Error();
}
}
async void LoadDownloads()
{
Debug.WriteLine("Loading download options...");
downloadSelector.Items.Clear();
YouTubeUri[] uris = await YouTube.GetUrisAsync(item.Id);
@@ -239,14 +198,13 @@ namespace FoxTube
MenuFlyoutItem menuItem = new MenuFlyoutItem()
{
Text = Methods.QualityToString(u.AudioQuality)
};
};
menuItem.Click += downloadItemSelected;
downloadSelector.Items.Add(menuItem);
}
}
else
download.Visibility = Visibility.Collapsed;
Debug.WriteLine("Done");
}
private void downloadItemSelected(object sender, RoutedEventArgs e)
@@ -256,10 +214,7 @@ namespace FoxTube
async void LoadRelatedVideos()
{
loadingRelated.Refresh();
loadingRelated.Visibility = Visibility.Visible;
SearchResource.ListRequest request = SecretsVault.IsAuthorized? SecretsVault.Service.Search.List("snippet") : SecretsVault.NoAuthService.Search.List("snippet");
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.RelatedToVideoId = videoId;
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
request.MaxResults = 20;
@@ -269,32 +224,6 @@ namespace FoxTube
foreach (SearchResult video in response.Items)
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)
@@ -330,7 +259,7 @@ namespace FoxTube
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)
@@ -339,22 +268,15 @@ namespace FoxTube
string timecode = player.elapsed.TotalSeconds > 10 ?
"&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)
{
playerPlaceholder.Children.Clear();
player = null;
player = new VideoPlayer();
Initialize(videoId);
}
private void LoadingScreen_RefreshPage(object sender, RoutedEventArgs e)
{
refresh_Click(this, null);
}
private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.NewSize.Width > 1000)
@@ -578,35 +500,5 @@ namespace FoxTube
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)
{
}
}
}