Search
This commit is contained in:
@@ -15,6 +15,10 @@ using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace FoxTube
|
||||
@@ -22,9 +26,33 @@ namespace FoxTube
|
||||
public sealed partial class ChannelCard : UserControl
|
||||
{
|
||||
string channelId;
|
||||
public ChannelCard()
|
||||
public ChannelCard(string id, string live)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id, live);
|
||||
}
|
||||
|
||||
public async void Initialize(string id, string live)
|
||||
{
|
||||
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
ApplicationName = this.GetType().ToString()
|
||||
});
|
||||
|
||||
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
|
||||
request.Id = id;
|
||||
ChannelListResponse response = await request.ExecuteAsync();
|
||||
|
||||
var item = response.Items[0];
|
||||
|
||||
channelName.Text = item.Snippet.Title;
|
||||
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
|
||||
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
if (live == "live")
|
||||
liveTag.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void AddInfo(string name, int videos, string avatarUrl, string channelUrl, int subs, Visibility live, bool logged)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</StackPanel>
|
||||
<ToggleButton Grid.Column="2" Height="50" Width="250" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
|
||||
<ToggleButton Grid.Column="3" Height="50" Width="50" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
|
||||
<!---->
|
||||
<!---->
|
||||
</Grid>
|
||||
<Frame Name="content" Grid.Row="2"/>
|
||||
</Grid>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Notification.cs" />
|
||||
<Compile Include="PlaylistCardWide.xaml.cs">
|
||||
<DependentUpon>PlaylistCardWide.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Search.xaml.cs">
|
||||
<DependentUpon>Search.xaml</DependentUpon>
|
||||
@@ -255,6 +258,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="PlaylistCardWide.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Search.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
+53
-26
@@ -106,55 +106,82 @@
|
||||
Width="42" Height="42" Margin="4"
|
||||
RelativePanel.AlignRightWithPanel="True"
|
||||
Background="Transparent"
|
||||
FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" FocusVisualSecondaryBrush="#66FFFFFF" FocusVisualPrimaryBrush="White" Foreground="Black"/>
|
||||
<Popup Margin="0,50,0,0" Grid.Column="9" Name="searchSuggestions" IsOpen="True" Visibility="Collapsed">
|
||||
<StackPanel>
|
||||
<StackPanel Width="350" Background="WhiteSmoke" Name="searchStandby">
|
||||
<TextBlock Padding="10,0,0,0" Text="Loading results... Please, wait."/>
|
||||
FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" Foreground="Black"/>
|
||||
<Popup Margin="0,50,0,0" Grid.Column="9" Name="searchSuggestions" IsOpen="True" Visibility="Visible">
|
||||
<StackPanel Padding="10" Background="WhiteSmoke" Width="350">
|
||||
<StackPanel Width="350" Name="searchStandby" Visibility="Visible">
|
||||
<TextBlock Text="Loading results... Please, wait."/>
|
||||
<ProgressBar IsIndeterminate="True"/>
|
||||
</StackPanel>
|
||||
<StackPanel Name="searchSuggestionsList" Visibility="Collapsed">
|
||||
<ListBox Width="350">
|
||||
<ListBoxItem Height="35" Padding="10,0,0,0">
|
||||
<ListBox Name="searchSuggestionsList" Visibility="Collapsed">
|
||||
<ListBoxItem Height="35" Padding="0" Name="s0" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 1"/>
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 0" Name="t0"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="10,0,0,0">
|
||||
<ListBoxItem Height="35" Padding="0" Name="s1" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 2"/>
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 1" Name="t1"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="10,0,0,0">
|
||||
<ListBoxItem Height="35" Padding="0" Name="s2" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 3"/>
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 2" Name="t2"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
<ListBox Width="350">
|
||||
<ListBoxItem Height="17" Margin="0" Padding="10,0,0,0" IsEnabled="False">
|
||||
<StackPanel Orientation="Horizontal" Margin="0" Padding="0, 0, 0, 0">
|
||||
<TextBlock Text="Search history" Foreground="Gray" FontSize="12" Margin="0" Padding="0, 0, 5, 0"/>
|
||||
<ListBoxItem Height="35" Padding="0" Name="s3" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 3" Name="t3"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="0" Name="s4" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 4" Name="t4"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Padding="0" IsEnabled="False">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Previous requests" Foreground="Gray" FontSize="12" Margin="0" Padding="0, 0, 5, 0"/>
|
||||
<Line X1="0" Y1="10" X2="250" Y2="10" Stroke="Gray" StrokeThickness="2"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="10,0,0,0">
|
||||
<ListBoxItem Height="35" Padding="0" Name="s6" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 4"/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 6" Name="t6"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="10,0,0,0">
|
||||
<ListBoxItem Height="35" Padding="0" Name="s7" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 5"/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 7" Name="t7"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="0" Name="s8" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 8" Name="t8"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="0" Name="s9" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 9" Name="t9"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Height="35" Padding="0" Name="s10" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||
<TextBlock Style="{StaticResource MenuItem}" Text="Suggestion 10" Name="t10"/>
|
||||
</StackPanel>
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Popup>
|
||||
</Grid>
|
||||
<SplitView Name="menu" Grid.Row="1" OpenPaneLength="250" CompactPaneLength="50" DisplayMode="CompactInline" IsPaneOpen="True" PaneClosing="menu_PaneClosed" PaneOpening="menu_PaneOpened">
|
||||
|
||||
@@ -19,6 +19,7 @@ using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using Windows.UI.Notifications;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.Storage;
|
||||
using System.Xml;
|
||||
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Services;
|
||||
@@ -39,6 +40,7 @@ namespace FoxTube
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
private bool loggedIn = false;
|
||||
UserCredential credential;
|
||||
public bool Logged
|
||||
{
|
||||
get
|
||||
@@ -331,7 +333,6 @@ namespace FoxTube
|
||||
|
||||
private async Task LogIn()
|
||||
{
|
||||
UserCredential credential;
|
||||
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///client_secrets.json"));
|
||||
|
||||
Debug.WriteLine("Exception accured after opening a stream");
|
||||
@@ -344,7 +345,7 @@ namespace FoxTube
|
||||
new FileDataStore(this.GetType().ToString())
|
||||
);
|
||||
Debug.WriteLine("200 OK");
|
||||
/*using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
|
||||
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
|
||||
GoogleClientSecrets.Load(stream).Secrets,
|
||||
@@ -353,12 +354,12 @@ namespace FoxTube
|
||||
CancellationToken.None,
|
||||
new FileDataStore(this.GetType().ToString())
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void searchField_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (searchField.Text != "")
|
||||
if (searchField.Text.Length > 2)
|
||||
{
|
||||
searchSuggestions.Visibility = Visibility.Visible;
|
||||
buildSearchSuggestionsTree(searchField.Text);
|
||||
@@ -419,5 +420,35 @@ namespace FoxTube
|
||||
searchSuggestions.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<UserControl
|
||||
x:Class="FoxTube.PlaylistCardWide"
|
||||
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"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="175">
|
||||
|
||||
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Image Name="thumbnail" Source="Assets/videoThumbSample.png"/>
|
||||
<!--<Image Source="https://i.ytimg.com/vi/XZQQcYnkumA/mqdefault.jpg"/>-->
|
||||
<Grid HorizontalAlignment="Right" Width="100">
|
||||
<Grid.Background>
|
||||
<AcrylicBrush TintColor="#7F000000" BackgroundSource="Backdrop" AlwaysUseFallback="False" TintOpacity="1" Opacity="0.97"/>
|
||||
</Grid.Background>
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<TextBlock HorizontalAlignment="Center" FontFamily="Segoe MDL2 Assets" Foreground="White" Text="" FontSize="30"/>
|
||||
<TextBlock Foreground="White" Text="30" HorizontalAlignment="Center" FontSize="20" Name="thumbCount"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Margin="10" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="75"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Name="title" TextWrapping="WrapWholeWords" Text="Subnautica - SAY GOODBYE TO SUBNAUTICA! We're Back Home! - Subnautica Ending (Full Release Gameplay)" FontSize="20" MaxLines="2"/>
|
||||
<TextBlock Name="info" Text="09-May-18 18:31 | 30 videos" Foreground="Gray"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="75"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Name="avatar" Width="75" HorizontalAlignment="Left"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
|
||||
<TextBlock Name="channelName" Text="IGP" FontSize="18"/>
|
||||
<TextBlock Name="channelSubs" Text="120,452 subscribers" Foreground="Gray"/>
|
||||
<HyperlinkButton Name="channelLink" Content="Go to channel" Padding="0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,67 @@
|
||||
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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Google.Apis.Util.Store;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
public sealed partial class PlaylistCardWide : UserControl
|
||||
{
|
||||
public PlaylistCardWide(string id)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id);
|
||||
}
|
||||
|
||||
public async void Initialize(string id)
|
||||
{
|
||||
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
ApplicationName = this.GetType().ToString()
|
||||
});
|
||||
|
||||
PlaylistsResource.ListRequest request = ytService.Playlists.List("snippet,contentDetails");
|
||||
request.Id = id;
|
||||
PlaylistListResponse response = await request.ExecuteAsync();
|
||||
|
||||
var item = response.Items[0];
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
info.Text = string.Format("{0} | {1} videos", item.Snippet.PublishedAt, item.ContentDetails.ItemCount);
|
||||
thumbCount.Text = item.ContentDetails.ItemCount.ToString();
|
||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
|
||||
var request1 = ytService.Channels.List("snippet,contentDetails,statistics");
|
||||
request1.Id = item.Snippet.ChannelId;
|
||||
ChannelListResponse response1 = await request1.ExecuteAsync();
|
||||
|
||||
var item1 = response1.Items[0];
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
|
||||
channelName.Text = item1.Snippet.Title;
|
||||
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
|
||||
channelLink.NavigateUri = new Uri("https://www.youtube.com/channel/" + item.Snippet.ChannelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-43
@@ -47,58 +47,24 @@ namespace FoxTube
|
||||
switch (result.Id.Kind)
|
||||
{
|
||||
case "youtube#video":
|
||||
AddVideo(result.Snippet.Title,
|
||||
"null", "null", result.Snippet.PublishedAt,
|
||||
result.Snippet.ChannelTitle, "null",
|
||||
result.Snippet.ChannelId, result.Snippet.Thumbnails.Medium.Url, "null", result.Snippet.LiveBroadcastContent);
|
||||
VideoCardWide vCard = new VideoCardWide(result.Id.VideoId);
|
||||
resultsList.Children.Add(vCard);
|
||||
break;
|
||||
|
||||
case "youtube#channel":
|
||||
AddChannel(result.Snippet.Title, 0, 0,
|
||||
result.Snippet.ChannelId, result.Snippet.Thumbnails.Medium.Url, result.Snippet.LiveBroadcastContent, logged);
|
||||
ChannelCard cCard = new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent);
|
||||
resultsList.Children.Add(cCard);
|
||||
break;
|
||||
|
||||
case "youtube#playlist":
|
||||
PlaylistCardWide pCard = new PlaylistCardWide(result.Id.PlaylistId);
|
||||
resultsList.Children.Add(pCard);
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.WriteLine("Skipped");
|
||||
break;
|
||||
}
|
||||
Google.Apis.YouTube.v3.Data.Video videItem = new Google.Apis.YouTube.v3.Data.Video();
|
||||
}
|
||||
|
||||
void AddVideo(string title,
|
||||
string duration, string views, DateTime? publicDate,
|
||||
string channelName, string subs,
|
||||
string channelId, string thumbUrl, string avatarUrl, string liveBroadcast)
|
||||
{
|
||||
Visibility live;
|
||||
if (liveBroadcast != "live")
|
||||
live = Visibility.Collapsed;
|
||||
else live = Visibility.Visible;
|
||||
|
||||
VideoCardWide card = new VideoCardWide();
|
||||
card.AddInfo(title,
|
||||
string.Format("{0} | {1} | {2}", duration, views, publicDate),
|
||||
thumbUrl, avatarUrl, string.Format("https://www.youtube.com/channel/{0}", channelId),
|
||||
channelName, subs, live);
|
||||
|
||||
resultsList.Children.Add(card);
|
||||
Debug.WriteLine("result item added");
|
||||
}
|
||||
|
||||
void AddChannel(string name, int followers, int uploads,
|
||||
string url, string avatar, string liveBroadcast, bool logged)
|
||||
{
|
||||
Visibility live;
|
||||
if (liveBroadcast != "live")
|
||||
live = Visibility.Collapsed;
|
||||
else live = Visibility.Visible;
|
||||
|
||||
ChannelCard card = new ChannelCard();
|
||||
card.AddInfo(name, uploads, avatar,
|
||||
"https://www.youtube.com/channel/" + url, followers, live, logged);
|
||||
|
||||
resultsList.Children.Add(card);
|
||||
Debug.WriteLine("result item added");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
-5
@@ -9,10 +9,33 @@
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="47"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="0*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Background="Red">
|
||||
<Pivot>
|
||||
<PivotItem Header="General">
|
||||
<local:General/>
|
||||
</PivotItem>
|
||||
<PivotItem Header="Personalization">
|
||||
|
||||
</PivotItem>
|
||||
<PivotItem Header="Account">
|
||||
|
||||
</PivotItem>
|
||||
<PivotItem Header="Leave feedback">
|
||||
<local:Feedback/>
|
||||
</PivotItem>
|
||||
<PivotItem Header="About us">
|
||||
<local:About/>
|
||||
</PivotItem>
|
||||
<PivotItem Header="Join beta program">
|
||||
|
||||
</PivotItem>
|
||||
<PivotItem Header="Help us translate this app">
|
||||
<local:Translate/>
|
||||
</PivotItem>
|
||||
</Pivot>
|
||||
<!--<Grid Grid.Row="0" Background="Red" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<HyperlinkButton Content="General" Foreground="White" Margin="10,8,10,10" Name="GeneralMenu" Click="General_Click"/>
|
||||
<HyperlinkButton Content="Personalization" Foreground="White" Margin="10,8,10,10" Name="PersonalizationMenu" Click="Personalization_Click" Visibility="Collapsed"/>
|
||||
@@ -22,7 +45,7 @@
|
||||
<HyperlinkButton Content="Join beta program" Foreground="White" Margin="10,8,10,10" Name="BetaMenu" Click="Beta_Click" Visibility="Collapsed"/>
|
||||
<HyperlinkButton Content="Help us translate this app" Foreground="White" Margin="10,8,10,10" Name="TranslateMenu" Click="Translate_Click" Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Frame Grid.Row="1" Name="settingsContent" />
|
||||
</Grid>-->
|
||||
<Frame Grid.Row="1" Name="settingsContent" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -14,28 +14,55 @@ using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Google.Apis.Util.Store;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
public sealed partial class VideoCardWide : UserControl
|
||||
{
|
||||
public VideoCardWide()
|
||||
public VideoCardWide(string id)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id);
|
||||
}
|
||||
public void AddInfo(string name, string description, string thumbUrl, string avatarUrl, string channelUrl, string channel, string subs, Visibility live)
|
||||
|
||||
public async void Initialize(string id)
|
||||
{
|
||||
title.Text = name;
|
||||
info.Text = description;
|
||||
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
ApplicationName = this.GetType().ToString()
|
||||
});
|
||||
|
||||
thumbnail.Source = new BitmapImage(new Uri(thumbUrl));
|
||||
//avatar.ProfilePicture = new BitmapImage(new Uri(avatarUrl));
|
||||
VideosResource.ListRequest request = ytService.Videos.List("snippet,contentDetails,statistics");
|
||||
request.Id = id;
|
||||
VideoListResponse response = await request.ExecuteAsync();
|
||||
|
||||
channelName.Text = channel;
|
||||
channelSubs.Text = string.Format("{0} subscribers", subs);
|
||||
channelLink.NavigateUri = new Uri(channelUrl);
|
||||
liveTag.Visibility = live;
|
||||
var item = response.Items[0];
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
info.Text = string.Format("{0} | {1} | {2} views", item.ContentDetails.Duration, item.Snippet.PublishedAt, item.Statistics.ViewCount);
|
||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
if (item.Snippet.LiveBroadcastContent == "live")
|
||||
liveTag.Visibility = Visibility.Visible;
|
||||
|
||||
var request1 = ytService.Channels.List("snippet,contentDetails,statistics");
|
||||
request1.Id = item.Snippet.ChannelId;
|
||||
ChannelListResponse response1 = await request1.ExecuteAsync();
|
||||
|
||||
var item1 = response1.Items[0];
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
|
||||
channelName.Text = item1.Snippet.Title;
|
||||
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
|
||||
channelLink.NavigateUri = new Uri("https://www.youtube.com/channel/" + item.Snippet.ChannelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="5">
|
||||
<ScrollViewer>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -39,4 +41,6 @@
|
||||
<local:VideoCard/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
+25
-11
@@ -120,33 +120,47 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<StackPanel Background="#FF333333" Padding="25">
|
||||
<Grid Background="#FF333333" Padding="25">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Warning! Mature content!" Foreground="White" FontSize="30"/>
|
||||
<Line Stroke="White" StrokeThickness="2" X1="0" X2="500"/>
|
||||
<StackPanel Name="proceedMature" Visibility="Visible">
|
||||
<Line Stroke="White" StrokeThickness="2" X1="0" X2="350"/>
|
||||
</StackPanel>
|
||||
<Grid Name="proceedMature" Visibility="Collapsed" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock TextWrapping="WrapWholeWords" Foreground="White" Text="This content isn't advised for children. It can represent violance, blood or sexual scenes." FontSize="20"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" VerticalAlignment="Bottom">
|
||||
<CheckBox Foreground="White">
|
||||
<TextBlock Foreground="White" Text="Don't show me it again"/>
|
||||
</CheckBox>
|
||||
<Button Content="Continue" Margin="5,0,0,0" Foreground="White" Background="Gray"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,0,0" Visibility="Collapsed" Name="signReq">
|
||||
</Grid>
|
||||
<Grid BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,0,0" Visibility="Visible" Name="signReq" Grid.Row="1" VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="40" Foreground="OrangeRed" Margin="5"/>
|
||||
<StackPanel HorizontalAlignment="Stretch">
|
||||
<StackPanel HorizontalAlignment="Stretch" Grid.Column="1">
|
||||
<TextBlock Text="Sign in into your account to continue" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
|
||||
<TextBlock Text="To watch this video you have to prove your age by sign in into your account which contains your age" Foreground="OrangeRed"/>
|
||||
</StackPanel>
|
||||
<Button Content="Sign in now" Foreground="White" Background="Gray" HorizontalAlignment="Right"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Visibility="Collapsed" Margin="0,10,0,0" Name="denied">
|
||||
<Button Content="Sign in now" Foreground="White" Background="Gray" HorizontalAlignment="Right" Grid.Column="1" Margin="0,0,10,0"/>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Visibility="Collapsed" Margin="0,10,0,0" Name="denied" Grid.Row="1" VerticalAlignment="Top">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="40" Foreground="OrangeRed" Margin="5"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Access denied" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
|
||||
<TextBlock Text="Your age is below 18. Come back later." Foreground="OrangeRed"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user