From 10575169aa345ca856f97fb2195ef1c5530df3e9 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Mon, 11 Jun 2018 13:10:37 +0300 Subject: [PATCH] Added functional video page & player --- FoxTube/FoxTube.csproj | 3 + FoxTube/MainPage.xaml.cs | 17 ++++- FoxTube/PlaylistCardWide.xaml.cs | 20 ++---- FoxTube/Settings.xaml | 6 +- FoxTube/Video.xaml | 59 ++++++---------- FoxTube/Video.xaml.cs | 40 ++++++++++- FoxTube/VideoCard.xaml | 2 +- FoxTube/VideoCard.xaml.cs | 14 ++-- FoxTube/VideoCardWide.xaml | 2 +- FoxTube/VideoCardWide.xaml.cs | 17 +++-- FoxTube/VideoPlayer.xaml | 35 +++++----- FoxTube/VideoPlayer.xaml.cs | 114 +++++++++++++++++++++++++++++-- 12 files changed, 235 insertions(+), 94 deletions(-) diff --git a/FoxTube/FoxTube.csproj b/FoxTube/FoxTube.csproj index 6dfeecd..0cb2d89 100644 --- a/FoxTube/FoxTube.csproj +++ b/FoxTube/FoxTube.csproj @@ -305,6 +305,9 @@ 3.0.0 + + 2.5.16 + 4.3.1 diff --git a/FoxTube/MainPage.xaml.cs b/FoxTube/MainPage.xaml.cs index 3bc7d6c..329d4c6 100644 --- a/FoxTube/MainPage.xaml.cs +++ b/FoxTube/MainPage.xaml.cs @@ -249,11 +249,11 @@ namespace FoxTube } else if (topHamburger.SelectedIndex == 1) { - content.Navigate(typeof(Video)); + /*content.Navigate(typeof(Video)); headerText.Text = "Video"; menu.DisplayMode = SplitViewDisplayMode.CompactOverlay; menu.IsPaneOpen = false; - isForcedCollapsed = true; + isForcedCollapsed = true;*/ } else if (bottomHaburger.SelectedIndex == 4) { @@ -386,7 +386,7 @@ namespace FoxTube XmlDocument doc = new XmlDocument(); await Task.Run(() => { - doc.Load(string.Format("http://suggestqueries.google.com/complete/search?output=toolbar&hl={0}&q={1}", (settings.Values["region"] as string)[1] + (settings.Values["region"] as string)[2], keyword)); + doc.Load(string.Format("http://suggestqueries.google.com/complete/search?output=toolbar&hl={0}&q={1}", (settings.Values["region"] as string)[0] + (settings.Values["region"] as string)[1], keyword)); }); for (int k = 0; k < 5; k++) @@ -590,6 +590,17 @@ namespace FoxTube page.Initialize(id); } + public void GoToVideo(string id) + { + headerText.Text = "Video"; + menu.DisplayMode = SplitViewDisplayMode.CompactOverlay; + menu.IsPaneOpen = false; + isForcedCollapsed = true; + + content.Navigate(typeof(Video)); + (content.Content as Video).Initialize(id); + } + private void Page_SizeChanged(object sender, SizeChangedEventArgs e) { if(isForcedCollapsed) diff --git a/FoxTube/PlaylistCardWide.xaml.cs b/FoxTube/PlaylistCardWide.xaml.cs index f96b800..52fd9b7 100644 --- a/FoxTube/PlaylistCardWide.xaml.cs +++ b/FoxTube/PlaylistCardWide.xaml.cs @@ -27,7 +27,8 @@ namespace FoxTube { public sealed partial class PlaylistCardWide : UserControl { - public string channelId; + public string playlistId; + Playlist item; public PlaylistCardWide(string id, bool hideAuthor = false) { this.InitializeComponent(); @@ -36,19 +37,13 @@ namespace FoxTube public async void Initialize(string id, bool hideAuthor) { - YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer() - { - ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0", - ApplicationName = this.GetType().ToString() - }); - - PlaylistsResource.ListRequest request = ytService.Playlists.List("snippet,contentDetails"); + PlaylistsResource.ListRequest request = SecretsVault.YoutubeService.Playlists.List("snippet,contentDetails"); request.Id = id; PlaylistListResponse response = await request.ExecuteAsync(); - var item = response.Items[0]; + item = response.Items[0]; - channelId = id; + playlistId = id; title.Text = item.Snippet.Title; info.Text = string.Format("{0} | {1} videos", item.Snippet.PublishedAt, item.ContentDetails.ItemCount); @@ -59,7 +54,7 @@ namespace FoxTube authorData.Visibility = Visibility.Collapsed; else { - var request1 = ytService.Channels.List("snippet,contentDetails,statistics"); + var request1 = SecretsVault.YoutubeService.Channels.List("snippet,contentDetails,statistics"); request1.Id = item.Snippet.ChannelId; ChannelListResponse response1 = await request1.ExecuteAsync(); @@ -74,8 +69,7 @@ namespace FoxTube private void channelLink_Click(object sender, RoutedEventArgs e) { - MainPage root = Window.Current.Content as MainPage; - root.GoToChannel(channelId); + ((Window.Current.Content as Frame).Content as MainPage).GoToChannel(item.Snippet.ChannelId); } } } diff --git a/FoxTube/Settings.xaml b/FoxTube/Settings.xaml index 224ace8..3ccfe8f 100644 --- a/FoxTube/Settings.xaml +++ b/FoxTube/Settings.xaml @@ -35,10 +35,8 @@ - - - - + + diff --git a/FoxTube/Video.xaml b/FoxTube/Video.xaml index 3ecf5c6..bf3a0e0 100644 --- a/FoxTube/Video.xaml +++ b/FoxTube/Video.xaml @@ -12,18 +12,13 @@ - - - - + + + - + - - - - - - - - - - - + + + - - + + - - - - - -