diff --git a/FoxTube/App.xaml b/FoxTube/App.xaml
index 3449269..6115628 100644
--- a/FoxTube/App.xaml
+++ b/FoxTube/App.xaml
@@ -18,6 +18,10 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/FoxTube/Channel.xaml.cs b/FoxTube/Channel.xaml.cs
index d7155dd..caf26c7 100644
--- a/FoxTube/Channel.xaml.cs
+++ b/FoxTube/Channel.xaml.cs
@@ -13,6 +13,11 @@ using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
+using Google.Apis.Services;
+using Google.Apis.YouTube.v3;
+using Google.Apis.YouTube.v3.Data;
+using Windows.UI.Xaml.Media.Imaging;
+
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube
@@ -22,10 +27,143 @@ namespace FoxTube
///
public sealed partial class Channel : Page
{
+ public string channelId;
+ public Google.Apis.YouTube.v3.Data.Channel item;
public Channel()
{
this.InitializeComponent();
- content.Navigate(typeof(ChannelVideos));
+ }
+
+ private void toAbout_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 4;
+ }
+
+ public async void Initialize(string id)
+ {
+ channelId = id;
+
+ YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
+ {
+ ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
+ ApplicationName = this.GetType().ToString()
+ });
+
+ ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics,brandingSettings");
+ request.Id = id;
+ ChannelListResponse response = await request.ExecuteAsync();
+
+ item = response.Items[0];
+
+ title.Text = item.Snippet.Title;
+ subscribers.Text = item.Statistics.SubscriberCount + " subscribers";
+ videosCount.Text = item.Statistics.VideoCount + " videos";
+
+ channelCover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerImageUrl));
+ avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
+
+ description.Text = item.Snippet.Description;
+ views.Text = item.Statistics.ViewCount.ToString();
+ registration.Text = item.Snippet.PublishedAt.ToString();
+ }
+
+ private void toVideos_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 0;
+ }
+
+ private async void toPlaylists_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 1;
+
+ if(playlists.Children.Count == 0)
+ {
+ YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
+ {
+ ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
+ ApplicationName = this.GetType().ToString()
+ });
+
+ PlaylistsResource.ListRequest request = ytService.Playlists.List("snippet,contentDetails");
+ request.MaxResults = 25;
+ request.ChannelId = channelId;
+ PlaylistListResponse response = await request.ExecuteAsync();
+
+ foreach (Playlist playlist in response.Items)
+ {
+ PlaylistCardWide playlistCard = new PlaylistCardWide(playlist.Id, true);
+ playlists.Children.Add(playlistCard);
+ }
+
+ playlistRing.IsActive = false;
+ playlistPane.Visibility = Visibility.Visible;
+ }
+ }
+
+ private void toCommunity_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 2;
+ }
+
+ private void toChannels_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 3;
+ }
+
+ private async void searchButton_Click(object sender, RoutedEventArgs e)
+ {
+ content.SelectedIndex = 5;
+
+ YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
+ {
+ ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
+ ApplicationName = this.GetType().ToString()
+ });
+
+ var searchListRequest = ytService.Search.List("snippet");
+ searchListRequest.Q = searchField.Text;
+ searchListRequest.MaxResults = 25;
+
+ var response = await searchListRequest.ExecuteAsync();
+
+ SetResults(searchField.Text, (int)response.PageInfo.TotalResults);
+ foreach (SearchResult result in response.Items)
+ AddItem(result);
+ searchRing.IsActive = false;
+ displaying.Visibility = Visibility.Visible;
+ }
+
+ public void SetResults(string keyword, int count)
+ {
+ searchTerm.Text = keyword;
+ if (count == 1000000)
+ resultsCount.Text = count + "+";
+ else
+ resultsCount.Text = count.ToString();
+ }
+
+ public void AddItem(SearchResult result)
+ {
+ switch (result.Id.Kind)
+ {
+ case "youtube#video":
+ VideoCardWide vCard = new VideoCardWide(result.Id.VideoId);
+ resultsList.Children.Add(vCard);
+ break;
+
+ case "youtube#channel":
+ 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:
+ break;
+ }
}
}
}
diff --git a/FoxTube/ChannelCard.xaml.cs b/FoxTube/ChannelCard.xaml.cs
index 601bc8e..566182b 100644
--- a/FoxTube/ChannelCard.xaml.cs
+++ b/FoxTube/ChannelCard.xaml.cs
@@ -46,6 +46,8 @@ namespace FoxTube
var item = response.Items[0];
+ channelId = id;
+
channelName.Text = item.Snippet.Title;
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
@@ -55,26 +57,11 @@ namespace FoxTube
liveTag.Visibility = Visibility.Visible;
}
- public void AddInfo(string name, int videos, string avatarUrl, string channelUrl, int subs, Visibility live, bool logged)
- {
- channelName.Text = name;
- videoCount.Text = string.Format("{0} videos", videos);
-
- avatar.ProfilePicture = new BitmapImage(new Uri(avatarUrl));
-
- subscribers.Text = string.Format("{0} subscribers", subs);
-
- channelId = channelUrl;
- liveTag.Visibility = live;
-
- if (!logged)
- subscriptionPane.Visibility = Visibility.Collapsed;
- }
-
private void Button_Click(object sender, RoutedEventArgs e)
{
- /*Debug.WriteLine(channelId);
- Process.Start(channelId);*/
+ Frame root = Window.Current.Content as Frame;
+ MainPage main = root.Content as MainPage;
+ main.GoToChannel(channelId);
}
}
}
diff --git a/FoxTube/ChannelVideos.xaml b/FoxTube/ChannelVideos.xaml
deleted file mode 100644
index 6d2d1ee..0000000
--- a/FoxTube/ChannelVideos.xaml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/FoxTube/ChannelVideos.xaml.cs b/FoxTube/ChannelVideos.xaml.cs
deleted file mode 100644
index 345b726..0000000
--- a/FoxTube/ChannelVideos.xaml.cs
+++ /dev/null
@@ -1,31 +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
-{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
- public sealed partial class ChannelVideos : Page
- {
- public ChannelVideos()
- {
- this.InitializeComponent();
- content.Navigate(typeof(VideoGrid));
- }
- }
-}
diff --git a/FoxTube/FoxTube.csproj b/FoxTube/FoxTube.csproj
index 9348a4f..a429d15 100644
--- a/FoxTube/FoxTube.csproj
+++ b/FoxTube/FoxTube.csproj
@@ -104,9 +104,6 @@
ChannelCard.xaml
-
- ChannelVideos.xaml
-
Feedback.xaml
@@ -116,9 +113,6 @@
Home.xaml
-
- MainFrame.xaml
-
MainPage.xaml
@@ -148,9 +142,6 @@
VideoGrid.xaml
-
- VideoList.xaml
-
VideoPlayer.xaml
@@ -234,10 +225,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -250,10 +237,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
MSBuild:Compile
Designer
@@ -290,10 +273,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
diff --git a/FoxTube/MainFrame.xaml b/FoxTube/MainFrame.xaml
deleted file mode 100644
index b095f5e..0000000
--- a/FoxTube/MainFrame.xaml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/FoxTube/MainFrame.xaml.cs b/FoxTube/MainFrame.xaml.cs
deleted file mode 100644
index 88a2dfa..0000000
--- a/FoxTube/MainFrame.xaml.cs
+++ /dev/null
@@ -1,30 +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
-{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
- public sealed partial class MainFrame : Page
- {
- public MainFrame()
- {
- this.InitializeComponent();
- }
- }
-}
diff --git a/FoxTube/MainPage.xaml b/FoxTube/MainPage.xaml
index 7ae3e73..02212a4 100644
--- a/FoxTube/MainPage.xaml
+++ b/FoxTube/MainPage.xaml
@@ -107,82 +107,14 @@
RelativePanel.AlignRightWithPanel="True"
Background="Transparent"
FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" Foreground="Black"/>
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/FoxTube/MainPage.xaml.cs b/FoxTube/MainPage.xaml.cs
index 78d6aab..00f6e08 100644
--- a/FoxTube/MainPage.xaml.cs
+++ b/FoxTube/MainPage.xaml.cs
@@ -563,5 +563,13 @@ namespace FoxTube
searchButton_Click(this, null);
}
}
+
+ public void GoToChannel(string id)
+ {
+ headerText.Text = "Channel overview";
+ content.Navigate(typeof(Channel));
+ Channel page = content.Content as Channel;
+ page.Initialize(id);
+ }
}
}
diff --git a/FoxTube/PlaylistCardWide.xaml b/FoxTube/PlaylistCardWide.xaml
index 1b9b78a..04b0647 100644
--- a/FoxTube/PlaylistCardWide.xaml
+++ b/FoxTube/PlaylistCardWide.xaml
@@ -33,7 +33,7 @@
-
+
@@ -42,7 +42,7 @@
-
+
diff --git a/FoxTube/PlaylistCardWide.xaml.cs b/FoxTube/PlaylistCardWide.xaml.cs
index 74f42a5..f96b800 100644
--- a/FoxTube/PlaylistCardWide.xaml.cs
+++ b/FoxTube/PlaylistCardWide.xaml.cs
@@ -27,13 +27,14 @@ namespace FoxTube
{
public sealed partial class PlaylistCardWide : UserControl
{
- public PlaylistCardWide(string id)
+ public string channelId;
+ public PlaylistCardWide(string id, bool hideAuthor = false)
{
this.InitializeComponent();
- Initialize(id);
+ Initialize(id, hideAuthor);
}
- public async void Initialize(string id)
+ public async void Initialize(string id, bool hideAuthor)
{
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
{
@@ -46,22 +47,35 @@ namespace FoxTube
PlaylistListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
+
+ channelId = id;
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();
+ if (hideAuthor)
+ authorData.Visibility = Visibility.Collapsed;
+ else
+ {
+ var request1 = ytService.Channels.List("snippet,contentDetails,statistics");
+ request1.Id = item.Snippet.ChannelId;
+ ChannelListResponse response1 = await request1.ExecuteAsync();
- var item1 = response1.Items[0];
+ 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);
+ 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);
+ }
+ }
+
+ private void channelLink_Click(object sender, RoutedEventArgs e)
+ {
+ MainPage root = Window.Current.Content as MainPage;
+ root.GoToChannel(channelId);
}
}
}
diff --git a/FoxTube/VideoCardWide.xaml b/FoxTube/VideoCardWide.xaml
index be10db2..04dea04 100644
--- a/FoxTube/VideoCardWide.xaml
+++ b/FoxTube/VideoCardWide.xaml
@@ -28,7 +28,7 @@
-
+
@@ -37,7 +37,7 @@
-
+
diff --git a/FoxTube/VideoCardWide.xaml.cs b/FoxTube/VideoCardWide.xaml.cs
index 50ecdf5..db9f516 100644
--- a/FoxTube/VideoCardWide.xaml.cs
+++ b/FoxTube/VideoCardWide.xaml.cs
@@ -27,6 +27,7 @@ namespace FoxTube
{
public sealed partial class VideoCardWide : UserControl
{
+ public string channeId;
public VideoCardWide(string id)
{
this.InitializeComponent();
@@ -46,7 +47,9 @@ namespace FoxTube
VideoListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
-
+
+ channeId = id;
+
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));
@@ -64,5 +67,11 @@ namespace FoxTube
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
channelLink.NavigateUri = new Uri("https://www.youtube.com/channel/" + item.Snippet.ChannelId);
}
+
+ private void channelLink_Click(object sender, RoutedEventArgs e)
+ {
+ MainPage root = Window.Current.Content as MainPage;
+ root.GoToChannel(channeId);
+ }
}
}
diff --git a/FoxTube/VideoList.xaml b/FoxTube/VideoList.xaml
deleted file mode 100644
index 7cf9438..0000000
--- a/FoxTube/VideoList.xaml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/FoxTube/VideoList.xaml.cs b/FoxTube/VideoList.xaml.cs
deleted file mode 100644
index 62cee54..0000000
--- a/FoxTube/VideoList.xaml.cs
+++ /dev/null
@@ -1,30 +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
-{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
- public sealed partial class VideoList : Page
- {
- public VideoList()
- {
- this.InitializeComponent();
- }
- }
-}