Playlist page complete
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
</Grid>-->
|
||||
|
||||
<Grid>
|
||||
<TextBox KeyUp="searchField_KeyUp" Name="searchField" ToolTipService.ToolTip="Search" Margin="4" Width="350" Height="42" Padding="10,10,45,0" PlaceholderText="Search" BorderThickness="0" Background="#7FFFFFFF" Text="kuplinov play" TextChanged="searchField_TextChanged" GotFocus="searchField_GotFocus"/>
|
||||
<TextBox KeyUp="searchField_KeyUp" Name="searchField" ToolTipService.ToolTip="Search" Margin="4" Width="350" Height="42" Padding="10,10,45,0" PlaceholderText="Search" BorderThickness="0" Background="#7FFFFFFF" Text="DAGmaes" TextChanged="searchField_TextChanged" GotFocus="searchField_GotFocus"/>
|
||||
<Button Name="searchButton" HorizontalAlignment="Right" Click="searchButton_Click"
|
||||
Width="42" Height="42" Margin="4"
|
||||
Background="Transparent"
|
||||
|
||||
@@ -547,6 +547,13 @@ namespace FoxTube
|
||||
|
||||
}
|
||||
|
||||
public void GoToPlaylist(string id)
|
||||
{
|
||||
MinimizeVideo();
|
||||
headerText.Text = "Playlist overview";
|
||||
content.Navigate(typeof(PlaylistPage), id);
|
||||
}
|
||||
|
||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (videoPlaceholder.Content != null)
|
||||
|
||||
@@ -5,10 +5,15 @@
|
||||
xmlns:local="using:FoxTube.Pages"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:foxtube="using:FoxTube"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<ScrollViewer>
|
||||
<Grid Name="grid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
<VisualState>
|
||||
@@ -24,45 +29,49 @@
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Margin="20" Grid.Column="1" x:Name="cover" HorizontalAlignment="Left">
|
||||
<Image Source="/Assets/videoThumbSample.png"/>
|
||||
<TextBlock FontSize="20" Text="[Title]" TextWrapping="WrapWholeWords"/>
|
||||
<TextBlock Foreground="Gray" Text="# videos | # views | Updated at: ##-##-## ##:##:##" TextWrapping="WrapWholeWords"/>
|
||||
<Button Margin="0,10,0,0" Background="Transparent">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Height="50"/>
|
||||
<TextBlock Grid.Column="1" Text="Channel name" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0" TextWrapping="WrapWholeWords"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<ScrollViewer>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Margin="20" Grid.Column="1" x:Name="cover" HorizontalAlignment="Left">
|
||||
<Image Source="/Assets/videoThumbSample.png" Name="thumbnail"/>
|
||||
<TextBlock FontSize="20" Text="[Title]" TextWrapping="WrapWholeWords" Name="title"/>
|
||||
<TextBlock Foreground="Gray" Text="# videos | # views | Updated at: ##-##-## ##:##:##" TextWrapping="WrapWholeWords" Name="info"/>
|
||||
<TextBlock Foreground="Gray" Text="description" TextWrapping="WrapWholeWords" Name="description"/>
|
||||
<Button Margin="0,10,0,0" Background="Transparent" Name="toChannel" Click="toChannel_Click">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Height="50" Name="avatar"/>
|
||||
<TextBlock Grid.Column="1" Text="Channel name" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0" TextWrapping="WrapWholeWords" Name="channelName"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<local:VideoGrid Grid.Column="1" Grid.Row="1"/>
|
||||
<local:VideoGrid Grid.Column="1" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
<CommandBar Grid.Row="2" Grid.ColumnSpan="2">
|
||||
<AppBarButton Icon="Globe" Label="Open in browser"/>
|
||||
<AppBarButton Icon="Add" Label="Add to">
|
||||
<AppBarButton.Flyout>
|
||||
<MenuFlyout>
|
||||
<CommandBar Grid.Row="2" Grid.ColumnSpan="2">
|
||||
<AppBarButton Icon="Globe" Label="Open in browser" Name="inBrowser" Click="inBrowser_Click"/>
|
||||
<AppBarButton Icon="Add" Label="Add to" IsEnabled="False">
|
||||
<AppBarButton.Flyout>
|
||||
<MenuFlyout>
|
||||
|
||||
</MenuFlyout>
|
||||
</AppBarButton.Flyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Refresh" Label="Refresh" Name="refresh" Click="refresh_Click"/>
|
||||
</CommandBar>
|
||||
|
||||
</MenuFlyout>
|
||||
</AppBarButton.Flyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Refresh" Label="Refresh"/>
|
||||
</CommandBar>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<foxtube:LoadingPage Grid.RowSpan="2" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
using System;
|
||||
using FoxTube.Controls;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
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.System;
|
||||
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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
@@ -22,9 +27,99 @@ namespace FoxTube.Pages
|
||||
/// </summary>
|
||||
public sealed partial class PlaylistPage : Page
|
||||
{
|
||||
string playlistId;
|
||||
Playlist item;
|
||||
|
||||
LoadingPage loading;
|
||||
VideoGrid list;
|
||||
|
||||
public PlaylistPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
loading = grid.Children[2] as LoadingPage;
|
||||
list = ((grid.Children[0] as ScrollViewer).Content as Grid).Children[1] as VideoGrid;
|
||||
loading.RefreshPage += refresh_Click;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
if (e.Parameter == null)
|
||||
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
|
||||
else
|
||||
Initialize(e.Parameter as string);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async void Initialize(string id)
|
||||
{
|
||||
loading.Refresh();
|
||||
|
||||
//try
|
||||
{
|
||||
playlistId = id;
|
||||
PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails");
|
||||
request.Id = id;
|
||||
|
||||
item = (await request.ExecuteAsync()).Items[0];
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
info.Text = $"{item.ContentDetails.ItemCount} videos";
|
||||
description.Text = item.Snippet.Description;
|
||||
|
||||
channelName.Text = item.Snippet.ChannelTitle;
|
||||
|
||||
try
|
||||
{
|
||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
ChannelsResource.ListRequest channelRequest = SecretsVault.NoAuthService.Channels.List("snippet");
|
||||
channelRequest.Id = item.Snippet.ChannelId;
|
||||
Google.Apis.YouTube.v3.Data.Channel channel = (await channelRequest.ExecuteAsync()).Items[0];
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(channel.Snippet.Thumbnails.Medium.Url));
|
||||
}
|
||||
catch { }
|
||||
|
||||
PlaylistItemsResource.ListRequest listRequest = SecretsVault.NoAuthService.PlaylistItems.List("contentDetails");
|
||||
listRequest.PlaylistId = item.Id;
|
||||
listRequest.MaxResults = 50;
|
||||
|
||||
PlaylistItemListResponse response = await listRequest.ExecuteAsync();
|
||||
|
||||
list.Clear();
|
||||
foreach (PlaylistItem i in response.Items)
|
||||
list.Add(new VideoCard(i.ContentDetails.VideoId));
|
||||
|
||||
while (response.NextPageToken != null)
|
||||
{
|
||||
listRequest.PageToken = response.NextPageToken;
|
||||
response = await listRequest.ExecuteAsync();
|
||||
|
||||
foreach (PlaylistItem i in response.Items)
|
||||
list.Add(new VideoCard(i.ContentDetails.VideoId));
|
||||
}
|
||||
|
||||
loading.Close();
|
||||
}
|
||||
//catch
|
||||
{
|
||||
loading.Error();
|
||||
}
|
||||
}
|
||||
|
||||
private void toChannel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
|
||||
}
|
||||
|
||||
private async void inBrowser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/playlist?list={item.Id}"));
|
||||
}
|
||||
|
||||
private void refresh_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Initialize(playlistId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user