Archived
1
0

Fullscreen and miniview mode fixed; Playlist tab on video page

This commit is contained in:
Michael Gordeev
2018-08-24 00:07:05 +03:00
parent ed29af9463
commit 4639b9c77b
6 changed files with 145 additions and 47 deletions
+9
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
@@ -47,6 +48,14 @@ namespace FoxTube
} catch { } } catch { }
try try
{ {
if (settings.Values["language"] == null)
{
List<string> cultures = new List<string>() { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" };
if (cultures.Contains(CultureInfo.InstalledUICulture.ThreeLetterISOLanguageName))
settings.Values.Add("language", "ru-RU");
else
settings.Values.Add("language", "en-US");
}
ApplicationLanguages.PrimaryLanguageOverride = (string)settings.Values["language"]; ApplicationLanguages.PrimaryLanguageOverride = (string)settings.Values["language"];
} }
catch { } catch { }
+1 -1
View File
@@ -42,7 +42,7 @@ namespace FoxTube
private bool miniView = false; private bool miniView = false;
private bool fullScreen = false; private bool fullScreen = false;
private bool pointerCaptured = false; public bool pointerCaptured = false;
public event ObjectEventHandler SetFullSize; public event ObjectEventHandler SetFullSize;
public event ObjectEventHandler NextClicked; public event ObjectEventHandler NextClicked;
+17 -4
View File
@@ -12,7 +12,20 @@
SizeChanged="Page_SizeChanged"> SizeChanged="Page_SizeChanged">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<NavigationView SelectedItem="toHome" BackRequested="nav_BackRequested" PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" IsPaneOpen="False" SelectionChanged="nav_SelectionChanged"> <VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="641"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="header.FontSize" Value="28"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<NavigationView SelectedItem="toHome" BackRequested="nav_BackRequested" PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" SelectionChanged="nav_SelectionChanged">
<NavigationView.MenuItems> <NavigationView.MenuItems>
<NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/> <NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/>
@@ -52,13 +65,13 @@
</NavigationView.AutoSuggestBox> </NavigationView.AutoSuggestBox>
<NavigationView.Header> <NavigationView.Header>
<Grid> <Grid Margin="10,25,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock FontSize="28" VerticalAlignment="Center" Text="Home" Name="header"/> <TextBlock FontSize="24" VerticalAlignment="Center" Text="Home" Name="header"/>
<StackPanel Orientation="Horizontal" Grid.Column="1" Margin="10,25,0,-11"> <StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Name="notificationMenu" Click="notificationMenu_Click" <Button Name="notificationMenu" Click="notificationMenu_Click"
FontFamily="Segoe MDL2 Assets" Content="&#xED0D;" FontFamily="Segoe MDL2 Assets" Content="&#xED0D;"
Width="50" Height="50" Background="Transparent" x:Uid="notifications" ToolTipService.ToolTip="Notifications"> Width="50" Height="50" Background="Transparent" x:Uid="notifications" ToolTipService.ToolTip="Notifications">
+14 -15
View File
@@ -40,6 +40,7 @@ using FoxTube.Controls;
using FoxTube.Pages; using FoxTube.Pages;
using Microsoft.Toolkit.Uwp.UI.Controls; using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using System.Net;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
@@ -63,14 +64,6 @@ namespace FoxTube
{ {
this.InitializeComponent(); this.InitializeComponent();
if (settings.Values["language"] == null)
{
List<string> cultures = new List<string>() { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" };
if(cultures.Contains(CultureInfo.InstalledUICulture.ThreeLetterISOLanguageName))
settings.Values.Add("language", "ru-RU");
else
settings.Values.Add("language", "en-US");
}
if (settings.Values["quality"] == null) if (settings.Values["quality"] == null)
settings.Values.Add("quality", 1); settings.Values.Add("quality", 1);
@@ -258,7 +251,6 @@ namespace FoxTube
nav.SelectedItem = toHome; nav.SelectedItem = toHome;
content.Navigate(typeof(Home)); content.Navigate(typeof(Home));
content.CacheSize = 0;
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
GoToVideo((videoPlaceholder.Content as VideoPage).videoId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
@@ -387,15 +379,20 @@ namespace FoxTube
public void Fullscreen(bool on) public void Fullscreen(bool on)
{ {
if(on) if (on)
{ {
nav.Margin = new Thickness(-48, -93, 0, 0); nav.OpenPaneLength = 0;
nav.OpenPaneLength = 48; nav.CompactPaneLength = 0;
if (nav.DisplayMode == NavigationViewDisplayMode.Minimal)
nav.Margin = new Thickness(0, -80, 0, 0);
else
nav.Margin = new Thickness(0, -91, 0, 0);
} }
else else
{ {
nav.Margin = new Thickness(0); nav.Margin = new Thickness(0);
nav.OpenPaneLength = 300; nav.OpenPaneLength = 300;
nav.CompactPaneLength = 48;
} }
} }
@@ -406,6 +403,7 @@ namespace FoxTube
ApplicationView.GetForCurrentView().ExitFullScreenMode(); ApplicationView.GetForCurrentView().ExitFullScreenMode();
Fullscreen(false); Fullscreen(false);
} }
(videoPlaceholder.Content as VideoPage).player.pointerCaptured = false;
videoPlaceholder.Content = null; videoPlaceholder.Content = null;
MaximizeVideo(); MaximizeVideo();
@@ -422,12 +420,13 @@ namespace FoxTube
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{ {
if(search.Text.Length > 2) if (search.Text.Length > 2 && args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{ {
try try
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&output=toolbar&hl={CultureInfo.CurrentUICulture.TwoLetterISOLanguageName}&q={search.Text}"); string reg = (settings.Values["region"] as string).Length > 2 ? (settings.Values["region"] as string).Remove(2) : (settings.Values["region"] as string);
doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&output=toolbar&hl={reg}&q={WebUtility.UrlEncode(search.Text)}");
List<string> suggestions = new List<string>(); List<string> suggestions = new List<string>();
@@ -436,7 +435,7 @@ namespace FoxTube
search.ItemsSource = suggestions; search.ItemsSource = suggestions;
} }
catch (System.Net.WebException) catch (WebException)
{ {
search.ItemsSource = new List<string>(); search.ItemsSource = new List<string>();
} }
+45 -24
View File
@@ -12,6 +12,21 @@
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged"> <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ratingPanel.(Grid.Row)" Value="0"/>
<Setter Target="ratingPanel.(HorizontalAlignment)" Value="Right"/>
<Setter Target="rating.Width" Value="250"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="400"/> <ColumnDefinition Width="400"/>
@@ -22,6 +37,10 @@
<StackPanel Margin="10" Name="descriptionPanel"> <StackPanel Margin="10" Name="descriptionPanel">
<TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/> <TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/>
<Grid> <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Padding="0" Background="Transparent" Margin="5" Name="gotoChannel" Click="gotoChannel_Click"> <Button Padding="0" Background="Transparent" Margin="5" Name="gotoChannel" Click="gotoChannel_Click">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<PersonPicture Name="channelAvatar" Width="90"/> <PersonPicture Name="channelAvatar" Width="90"/>
@@ -32,9 +51,9 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Button> </Button>
<StackPanel HorizontalAlignment="Right"> <StackPanel HorizontalAlignment="Stretch" Name="ratingPanel" Grid.Row="1">
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/> <TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
<ProgressBar Name="rating" Width="250" Background="Green" Foreground="Red"/> <ProgressBar Name="rating" Background="Green" Foreground="Red"/>
<Grid> <Grid>
<FontIcon Foreground="Gray" <FontIcon Foreground="Gray"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@@ -104,29 +123,31 @@
<pages:CommentsPage/> <pages:CommentsPage/>
</PivotItem> </PivotItem>
<PivotItem Header="Playlist" Name="playlist"> <PivotItem Header="Playlist" Name="playlist">
<StackPanel> <ScrollViewer>
<StackPanel Padding="8" Background="WhiteSmoke"> <StackPanel>
<TextBlock Text="Music" FontSize="26" TextWrapping="WrapWholeWords" Name="playlistName"/> <StackPanel Padding="8" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}">
<TextBlock Text="DAGames" Name="playlistChannel"/> <TextBlock Text="Music" FontSize="26" TextWrapping="WrapWholeWords" Name="playlistName"/>
<TextBlock Text="15/155" Name="playlistCounter"/> <TextBlock Text="DAGames" Name="playlistChannel"/>
</StackPanel> <TextBlock Text="15/155" Name="playlistCounter"/>
<ScrollViewer>
<StackPanel Name="playlistList">
<Button HorizontalAlignment="Stretch" Height="75" HorizontalContentAlignment="Stretch" Background="Transparent">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="15" VerticalAlignment="Center" Margin="0,0,8,0"/>
<Image Grid.Column="1" Source="/Assets/videoThumbSample.png"/>
<TextBlock Grid.Column="2" Margin="8,0,0,0" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Text="Title"/>
</Grid>
</Button>
</StackPanel> </StackPanel>
</ScrollViewer> <ListBox Background="Transparent" SelectionChanged="ListBox_SelectionChanged" Name="playlistList">
</StackPanel> <ListBox.ItemTemplate>
<DataTemplate>
<Grid Tag="{Binding Path=Id}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=Number}" VerticalAlignment="Center" Margin="0,0,8,0"/>
<Image Grid.Column="1" Source="{Binding Path=Thumbnail}" Height="65"/>
<TextBlock Grid.Column="2" Margin="8,0,0,0" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Text="{Binding Path=Title}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
</PivotItem> </PivotItem>
</Pivot> </Pivot>
</Grid> </Grid>
+59 -3
View File
@@ -39,6 +39,21 @@ namespace FoxTube.Pages
{ {
public enum Rating { None, Like, Dislike } public enum Rating { None, Like, Dislike }
public class VideoPlaylistItem
{
public int Number { get; set; }
public string Thumbnail { get; private set; } = "/Assets/videoThumbSample.png";
public string Id { get; private set; }
public string Title { get; private set; }
public VideoPlaylistItem(string image, string title, string id)
{
Thumbnail = image;
Title = title;
Id = id;
}
}
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// An empty page that can be used on its own or navigated to within a Frame.
/// </summary> /// </summary>
@@ -116,6 +131,10 @@ namespace FoxTube.Pages
if (ids[1] != null) if (ids[1] != null)
{ {
playlistId = ids[1];
List<VideoPlaylistItem> items = new List<VideoPlaylistItem>();
VideoPlaylistItem selection = null;
PlaylistsResource.ListRequest playlistRequest = SecretsVault.Service.Playlists.List("snippet,contentDetails"); PlaylistsResource.ListRequest playlistRequest = SecretsVault.Service.Playlists.List("snippet,contentDetails");
playlistRequest.Id = ids[1]; playlistRequest.Id = ids[1];
Playlist playlistItem = (await playlistRequest.ExecuteAsync()).Items[0]; Playlist playlistItem = (await playlistRequest.ExecuteAsync()).Items[0];
@@ -124,10 +143,40 @@ namespace FoxTube.Pages
playlistChannel.Text = playlistItem.Snippet.ChannelTitle; playlistChannel.Text = playlistItem.Snippet.ChannelTitle;
PlaylistItemsResource.ListRequest listRequest = SecretsVault.Service.PlaylistItems.List("snippet"); PlaylistItemsResource.ListRequest listRequest = SecretsVault.Service.PlaylistItems.List("snippet");
listRequest.MaxResults = 50;
listRequest.PlaylistId = ids[1]; listRequest.PlaylistId = ids[1];
PlaylistItemListResponse listResponse = await listRequest.ExecuteAsync(); PlaylistItemListResponse listResponse = await listRequest.ExecuteAsync();
//Initialize playlist tab foreach (PlaylistItem i in listResponse.Items)
{
items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.Snippet.ResourceId.VideoId));
if (items.Last().Id == videoId)
selection = items.Last();
}
string token = listResponse.NextPageToken;
while(!string.IsNullOrWhiteSpace(token))
{
listRequest.PageToken = token;
listResponse = await listRequest.ExecuteAsync();
foreach (PlaylistItem i in listResponse.Items)
{
items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.ContentDetails.VideoId));
if (items.Last().Id == videoId)
selection = items.Last();
}
token = listResponse.NextPageToken;
}
for (int k = 0; k < items.Count; k++)
items[k].Number = k + 1;
playlistCounter.Text = $"{items.IndexOf(selection) + 1}/{playlistItem.ContentDetails.ItemCount}";
playlistList.ItemsSource = items;
playlistList.SelectedItem = selection;
} }
else else
pivot.Items.Remove(playlist); pivot.Items.Remove(playlist);
@@ -197,9 +246,9 @@ namespace FoxTube.Pages
{ {
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch catch (Exception e)
{ {
loading.Error(); loading.Error(e.HResult.ToString(), e.Message);
} }
} }
@@ -303,6 +352,7 @@ namespace FoxTube.Pages
private void grid_SizeChanged(object sender, SizeChangedEventArgs e) private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
Debug.WriteLine(e.NewSize.Width);
if (e.NewSize.Width > 1000) if (e.NewSize.Width > 1000)
wide = true; wide = true;
else else
@@ -456,5 +506,11 @@ namespace FoxTube.Pages
break; break;
} }
} }
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((e.AddedItems[0] as VideoPlaylistItem).Id != videoId)
Methods.MainPage.GoToVideo((e.AddedItems[0] as VideoPlaylistItem).Id, playlistId);
}
} }
} }