Playlist page complete
This commit is contained in:
@@ -53,8 +53,8 @@ namespace FoxTube.Controls
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Standard.Url));
|
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||||
avatar.ProfilePicture = new BitmapImage(new Uri((await r.ExecuteAsync()).Items[0].Snippet.Thumbnails.Standard.Url));
|
avatar.ProfilePicture = new BitmapImage(new Uri((await r.ExecuteAsync()).Items[0].Snippet.Thumbnails.Medium.Url));
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace FoxTube.Controls
|
|||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//Goto playlist
|
Methods.MainPage.GoToPlaylist(item.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
</Grid>-->
|
</Grid>-->
|
||||||
|
|
||||||
<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"
|
<Button Name="searchButton" HorizontalAlignment="Right" Click="searchButton_Click"
|
||||||
Width="42" Height="42" Margin="4"
|
Width="42" Height="42" Margin="4"
|
||||||
Background="Transparent"
|
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)
|
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (videoPlaceholder.Content != null)
|
if (videoPlaceholder.Content != null)
|
||||||
|
|||||||
@@ -5,10 +5,15 @@
|
|||||||
xmlns:local="using:FoxTube.Pages"
|
xmlns:local="using:FoxTube.Pages"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:foxtube="using:FoxTube"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
|
|
||||||
<ScrollViewer>
|
<Grid Name="grid">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup>
|
<VisualStateGroup>
|
||||||
<VisualState>
|
<VisualState>
|
||||||
@@ -24,45 +29,49 @@
|
|||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
<Grid>
|
<ScrollViewer>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid>
|
||||||
<ColumnDefinition Width="auto"/>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
<ColumnDefinition Width="*"/>
|
||||||
<Grid.RowDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0" Margin="20" Grid.Column="1" x:Name="cover" HorizontalAlignment="Left">
|
<StackPanel Grid.Row="0" Margin="20" Grid.Column="1" x:Name="cover" HorizontalAlignment="Left">
|
||||||
<Image Source="/Assets/videoThumbSample.png"/>
|
<Image Source="/Assets/videoThumbSample.png" Name="thumbnail"/>
|
||||||
<TextBlock FontSize="20" Text="[Title]" TextWrapping="WrapWholeWords"/>
|
<TextBlock FontSize="20" Text="[Title]" TextWrapping="WrapWholeWords" Name="title"/>
|
||||||
<TextBlock Foreground="Gray" Text="# videos | # views | Updated at: ##-##-## ##:##:##" TextWrapping="WrapWholeWords"/>
|
<TextBlock Foreground="Gray" Text="# videos | # views | Updated at: ##-##-## ##:##:##" TextWrapping="WrapWholeWords" Name="info"/>
|
||||||
<Button Margin="0,10,0,0" Background="Transparent">
|
<TextBlock Foreground="Gray" Text="description" TextWrapping="WrapWholeWords" Name="description"/>
|
||||||
<Grid>
|
<Button Margin="0,10,0,0" Background="Transparent" Name="toChannel" Click="toChannel_Click">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
<ColumnDefinition/>
|
||||||
<PersonPicture Height="50"/>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Grid.Column="1" Text="Channel name" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0" TextWrapping="WrapWholeWords"/>
|
<PersonPicture Height="50" Name="avatar"/>
|
||||||
</Grid>
|
<TextBlock Grid.Column="1" Text="Channel name" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0" TextWrapping="WrapWholeWords" Name="channelName"/>
|
||||||
</Button>
|
</Grid>
|
||||||
</StackPanel>
|
</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">
|
<CommandBar Grid.Row="2" Grid.ColumnSpan="2">
|
||||||
<AppBarButton Icon="Globe" Label="Open in browser"/>
|
<AppBarButton Icon="Globe" Label="Open in browser" Name="inBrowser" Click="inBrowser_Click"/>
|
||||||
<AppBarButton Icon="Add" Label="Add to">
|
<AppBarButton Icon="Add" Label="Add to" IsEnabled="False">
|
||||||
<AppBarButton.Flyout>
|
<AppBarButton.Flyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
|
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</AppBarButton.Flyout>
|
</AppBarButton.Flyout>
|
||||||
</AppBarButton>
|
</AppBarButton>
|
||||||
<AppBarButton Icon="Refresh" Label="Refresh"/>
|
<AppBarButton Icon="Refresh" Label="Refresh" Name="refresh" Click="refresh_Click"/>
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
</Grid>
|
|
||||||
</ScrollViewer>
|
<foxtube:LoadingPage Grid.RowSpan="2" Visibility="Collapsed"/>
|
||||||
|
</Grid>
|
||||||
</Page>
|
</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.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
using Windows.Foundation.Collections;
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.System;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
using Windows.UI.Xaml.Data;
|
using Windows.UI.Xaml.Data;
|
||||||
using Windows.UI.Xaml.Input;
|
using Windows.UI.Xaml.Input;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
// 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
|
||||||
@@ -22,9 +27,99 @@ namespace FoxTube.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class PlaylistPage : Page
|
public sealed partial class PlaylistPage : Page
|
||||||
{
|
{
|
||||||
|
string playlistId;
|
||||||
|
Playlist item;
|
||||||
|
|
||||||
|
LoadingPage loading;
|
||||||
|
VideoGrid list;
|
||||||
|
|
||||||
public PlaylistPage()
|
public PlaylistPage()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
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