Development 128
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static Google.Apis.YouTube.v3.SearchResource.ListRequest;
|
||||||
|
|
||||||
namespace FoxTube
|
namespace FoxTube
|
||||||
{
|
{
|
||||||
@@ -10,7 +11,7 @@ namespace FoxTube
|
|||||||
|
|
||||||
public delegate void ObjectEventHandler(object sender, params object[] args);
|
public delegate void ObjectEventHandler(object sender, params object[] args);
|
||||||
|
|
||||||
public class SearchParameters
|
/*public class SearchParameters
|
||||||
{
|
{
|
||||||
public string ChannelId { get; set; }
|
public string ChannelId { get; set; }
|
||||||
public string Term { get; set; }
|
public string Term { get; set; }
|
||||||
@@ -20,5 +21,129 @@ namespace FoxTube
|
|||||||
ChannelId = channelId;
|
ChannelId = channelId;
|
||||||
Term = term;
|
Term = term;
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public class SearchParameters
|
||||||
|
{
|
||||||
|
public class Filters
|
||||||
|
{
|
||||||
|
public static class Enumerations
|
||||||
|
{
|
||||||
|
public enum Order { Relevance, Date, Views, Rating, Title }
|
||||||
|
public enum Type { All, Video, Channel, Playlist }
|
||||||
|
public enum Date { Any, Hour, Today, Week, Month, Year }
|
||||||
|
public enum Duration { Any, Long, Medium, Short }
|
||||||
|
public enum ConversionType { Order, Type, Date, Duration, HD, ThreeD, Captions, LiveEvent, CreativeCommons }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Enumerations.Order Order { get; set; } = Enumerations.Order.Relevance;
|
||||||
|
public Enumerations.Date Date { get; set; } = Enumerations.Date.Any;
|
||||||
|
public Enumerations.Type Type { get; set; } = Enumerations.Type.All;
|
||||||
|
public Enumerations.Duration Duration { get; set; } = Enumerations.Duration.Any;
|
||||||
|
public bool HD { get; set; } = false;
|
||||||
|
public bool Is3D { get; set; } = false;
|
||||||
|
public bool Captions { get; set; } = false;
|
||||||
|
public bool LiveEvent { get; set; } = false;
|
||||||
|
public bool CreativeCommons { get; set; } = false;
|
||||||
|
|
||||||
|
public object GetParameter(Enumerations.ConversionType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Enumerations.ConversionType.Captions:
|
||||||
|
if (Captions)
|
||||||
|
return VideoCaptionEnum.ClosedCaption;
|
||||||
|
else return null;
|
||||||
|
case Enumerations.ConversionType.CreativeCommons:
|
||||||
|
if (CreativeCommons)
|
||||||
|
return VideoLicenseEnum.CreativeCommon;
|
||||||
|
else return null;
|
||||||
|
case Enumerations.ConversionType.Date:
|
||||||
|
switch(Date)
|
||||||
|
{
|
||||||
|
case Enumerations.Date.Any:
|
||||||
|
return null;
|
||||||
|
case Enumerations.Date.Hour:
|
||||||
|
return DateTime.Now.Subtract(TimeSpan.FromHours(1));
|
||||||
|
case Enumerations.Date.Today:
|
||||||
|
return DateTime.Now.Subtract(TimeSpan.FromDays(1));
|
||||||
|
case Enumerations.Date.Week:
|
||||||
|
return DateTime.Now.Subtract(TimeSpan.FromDays(7));
|
||||||
|
case Enumerations.Date.Month:
|
||||||
|
return DateTime.Now.Subtract(TimeSpan.FromDays(31));
|
||||||
|
case Enumerations.Date.Year:
|
||||||
|
return DateTime.Now.Subtract(TimeSpan.FromDays(365));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Enumerations.ConversionType.Duration:
|
||||||
|
return (VideoDurationEnum)Duration;
|
||||||
|
case Enumerations.ConversionType.HD:
|
||||||
|
if (HD)
|
||||||
|
return VideoDefinitionEnum.High;
|
||||||
|
else return null;
|
||||||
|
case Enumerations.ConversionType.LiveEvent:
|
||||||
|
if (LiveEvent)
|
||||||
|
return EventTypeEnum.Live;
|
||||||
|
else return null;
|
||||||
|
case Enumerations.ConversionType.Order:
|
||||||
|
Dictionary<int, int> d = new Dictionary<int, int>()
|
||||||
|
{
|
||||||
|
{ 0, 2 },
|
||||||
|
{ 1, 0 },
|
||||||
|
{ 2, 5 },
|
||||||
|
{ 3, 1 },
|
||||||
|
{ 4, 3 }
|
||||||
|
};
|
||||||
|
return (OrderEnum)d[(int)Order];
|
||||||
|
case Enumerations.ConversionType.ThreeD:
|
||||||
|
if (Is3D)
|
||||||
|
return VideoDimensionEnum.Value3d;
|
||||||
|
else return null;
|
||||||
|
case Enumerations.ConversionType.Type:
|
||||||
|
switch(Type)
|
||||||
|
{
|
||||||
|
case Enumerations.Type.All:
|
||||||
|
return "video,channel,playlist";
|
||||||
|
case Enumerations.Type.Channel:
|
||||||
|
return "channel";
|
||||||
|
case Enumerations.Type.Playlist:
|
||||||
|
return "playlist";
|
||||||
|
case Enumerations.Type.Video:
|
||||||
|
return "video";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Term { get; private set; }
|
||||||
|
public string Channel { get; private set; }
|
||||||
|
public Filters Filter { get; private set; } = new Filters();
|
||||||
|
|
||||||
|
|
||||||
|
public SearchParameters(string term)
|
||||||
|
{
|
||||||
|
Term = term;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchParameters(string term, Filters filters)
|
||||||
|
{
|
||||||
|
Term = term;
|
||||||
|
Filter = filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchParameters(string term, string channelId)
|
||||||
|
{
|
||||||
|
Term = term;
|
||||||
|
Channel = channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchParameters(string term, string channelId, Filters filters)
|
||||||
|
{
|
||||||
|
Term = term;
|
||||||
|
Channel = channelId;
|
||||||
|
Filter = filters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
RequestedTheme="Dark"
|
RequestedTheme="Dark"
|
||||||
PointerMoved="UserControl_PointerMoved"
|
PointerMoved="UserControl_PointerMoved"
|
||||||
PointerExited="UserControl_PointerExited"
|
PointerExited="UserControl_PointerExited"
|
||||||
PointerEntered="UserControl_PointerEntered">
|
PointerEntered="UserControl_PointerEntered"
|
||||||
|
KeyUp="UserControl_KeyUp">
|
||||||
|
|
||||||
<Grid Background="White" Name="grid" Tapped="UserControl_Tapped">
|
<Grid Background="White" Name="grid" Tapped="UserControl_Tapped">
|
||||||
<MediaElement IsDoubleTapEnabled="False" CurrentStateChanged="videoSource_CurrentStateChanged" AutoPlay="False" Name="videoSource" AreTransportControlsEnabled="False" PosterSource="ms-appx:///Assets/videoThumbSample.png"/>
|
<MediaElement IsDoubleTapEnabled="False" CurrentStateChanged="videoSource_CurrentStateChanged" AutoPlay="False" Name="videoSource" AreTransportControlsEnabled="False" PosterSource="ms-appx:///Assets/videoThumbSample.png"/>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ using Windows.ApplicationModel.Core;
|
|||||||
using Windows.UI;
|
using Windows.UI;
|
||||||
using Windows.Graphics.Display;
|
using Windows.Graphics.Display;
|
||||||
using Windows.Media.Casting;
|
using Windows.Media.Casting;
|
||||||
|
using YoutubeExplode.Models.MediaStreams;
|
||||||
|
|
||||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||||
|
|
||||||
@@ -659,12 +660,14 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void fwd30_Click(object sender, RoutedEventArgs e)
|
private void fwd30_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
videoSource.Position = elapsed.Add(TimeSpan.FromSeconds(30));
|
if(remaining.TotalSeconds >= 30)
|
||||||
|
videoSource.Position = elapsed.Add(TimeSpan.FromSeconds(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void back10_Click(object sender, RoutedEventArgs e)
|
private void back10_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
videoSource.Position = elapsed.Subtract(TimeSpan.FromSeconds(10));
|
if (elapsed.TotalSeconds >= 10)
|
||||||
|
videoSource.Position = elapsed.Subtract(TimeSpan.FromSeconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UserControl_PointerExited(object sender, PointerRoutedEventArgs e)
|
private void UserControl_PointerExited(object sender, PointerRoutedEventArgs e)
|
||||||
@@ -800,5 +803,26 @@ namespace FoxTube
|
|||||||
if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && !miniView)
|
if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && !miniView)
|
||||||
play_Click(this, null);
|
play_Click(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UserControl_KeyUp(object sender, KeyRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
switch(e.Key)
|
||||||
|
{
|
||||||
|
case Windows.System.VirtualKey.Escape:
|
||||||
|
case Windows.System.VirtualKey.F11:
|
||||||
|
if (fullScreen)
|
||||||
|
fullscreen_Click(this, null);
|
||||||
|
break;
|
||||||
|
case Windows.System.VirtualKey.Space:
|
||||||
|
play_Click(this, null);
|
||||||
|
break;
|
||||||
|
case Windows.System.VirtualKey.Left:
|
||||||
|
back10_Click(this, null);
|
||||||
|
break;
|
||||||
|
case Windows.System.VirtualKey.Right:
|
||||||
|
fwd30_Click(this, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,6 +428,9 @@
|
|||||||
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
|
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
|
||||||
<Version>4.3.1</Version>
|
<Version>4.3.1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="YoutubeExplode">
|
||||||
|
<Version>4.3.1</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="FoxTube_TemporaryKey.pfx" />
|
<None Include="FoxTube_TemporaryKey.pfx" />
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ namespace FoxTube.Pages
|
|||||||
|
|
||||||
playlistRequest = SecretsVault.Service.Search.List("id");
|
playlistRequest = SecretsVault.Service.Search.List("id");
|
||||||
playlistRequest.ChannelId = channelId;
|
playlistRequest.ChannelId = channelId;
|
||||||
|
playlistRequest.Order = SearchResource.ListRequest.OrderEnum.Date;
|
||||||
playlistRequest.Type = "playlist";
|
playlistRequest.Type = "playlist";
|
||||||
playlistRequest.MaxResults = 48;
|
playlistRequest.MaxResults = 48;
|
||||||
|
|
||||||
@@ -276,18 +277,21 @@ namespace FoxTube.Pages
|
|||||||
|
|
||||||
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||||
{
|
{
|
||||||
if (content.Items.Count == 4)
|
if(search.Text.Length > 2)
|
||||||
(((content.Items[3] as PivotItem).Content as Frame).Content as Search).Initialize(new SearchParameters(item.Id, search.Text));
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
content.Items.Add(new PivotItem()
|
if (content.Items.Count == 4)
|
||||||
|
((content.Items[3] as PivotItem).Content as Frame).Navigate(typeof(Search), new SearchParameters(search.Text, item.Id));
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Content = new Frame()
|
content.Items.Add(new PivotItem()
|
||||||
});
|
{
|
||||||
((content.Items[3] as PivotItem).Content as Frame).Navigate(typeof(Search), new SearchParameters(item.Id, search.Text));
|
Content = new Frame()
|
||||||
}
|
});
|
||||||
|
((content.Items[3] as PivotItem).Content as Frame).Navigate(typeof(Search), new SearchParameters(search.Text, item.Id));
|
||||||
|
}
|
||||||
|
|
||||||
content.SelectedIndex = 3;
|
content.SelectedIndex = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh_Click(object sender, RoutedEventArgs e)
|
private void refresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ using FoxTube.Pages;
|
|||||||
using Microsoft.Toolkit.Uwp.UI.Controls;
|
using Microsoft.Toolkit.Uwp.UI.Controls;
|
||||||
using Windows.ApplicationModel;
|
using Windows.ApplicationModel;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using Windows.UI.Popups;
|
||||||
|
using Windows.Networking.Connectivity;
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@@ -303,18 +305,10 @@ namespace FoxTube
|
|||||||
SecretsVault.Deauthenticate();
|
SecretsVault.Deauthenticate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToSearch(string keyword = null)
|
public void GoToSearch(SearchParameters args)
|
||||||
{
|
{
|
||||||
if(keyword != null)
|
MinimizeAsInitializer();
|
||||||
search.Text = keyword;
|
content.Navigate(typeof(Search), args);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(search.Text))
|
|
||||||
{
|
|
||||||
if (!(content.Content is Search))
|
|
||||||
content.Navigate(typeof(Search), search.Text);
|
|
||||||
else if ((content.Content as Search).Term != search.Text)
|
|
||||||
(content.Content as Search).Initialize(search.Text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToChannel(string id)
|
public void GoToChannel(string id)
|
||||||
@@ -323,8 +317,30 @@ namespace FoxTube
|
|||||||
content.Navigate(typeof(ChannelPage), id);
|
content.Navigate(typeof(ChannelPage), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToVideo(string id, string playlistId = null)
|
public async void GoToVideo(string id, string playlistId = null)
|
||||||
{
|
{
|
||||||
|
var connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost();
|
||||||
|
if ((bool)settings.Values["moblieWarning"] && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable))
|
||||||
|
{
|
||||||
|
bool cancel = false;
|
||||||
|
MessageDialog dialog = new MessageDialog("You are on metered connection now. Additional charges may apply. Do you want to continue?")
|
||||||
|
{
|
||||||
|
DefaultCommandIndex = 2,
|
||||||
|
CancelCommandIndex = 1
|
||||||
|
};
|
||||||
|
dialog.Commands.Add(new UICommand("Yes"));
|
||||||
|
dialog.Commands.Add(new UICommand("No", (command) => cancel = true));
|
||||||
|
dialog.Commands.Add(new UICommand("Add to 'Watch later' playlist", (command) =>
|
||||||
|
{
|
||||||
|
//TO-DO: Adding video to "Watch later"
|
||||||
|
cancel = true;
|
||||||
|
}));
|
||||||
|
await dialog.ShowAsync();
|
||||||
|
|
||||||
|
if (cancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nav.IsPaneOpen = false;
|
nav.IsPaneOpen = false;
|
||||||
|
|
||||||
videoPlaceholder.Content = null;
|
videoPlaceholder.Content = null;
|
||||||
@@ -421,7 +437,7 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
private void search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||||
{
|
{
|
||||||
GoToSearch();
|
GoToSearch(new SearchParameters(search.Text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||||
|
|||||||
@@ -46,9 +46,9 @@
|
|||||||
</ComboBox>
|
</ComboBox>
|
||||||
<ComboBox Visibility="Collapsed" Name="duration" Header="Duration" Width="150" SelectedIndex="0">
|
<ComboBox Visibility="Collapsed" Name="duration" Header="Duration" Width="150" SelectedIndex="0">
|
||||||
<ComboBoxItem Content="Any"/>
|
<ComboBoxItem Content="Any"/>
|
||||||
<ComboBoxItem Content="Short (< 4 minutes)"/>
|
|
||||||
<ComboBoxItem Content="Medium"/>
|
|
||||||
<ComboBoxItem Content="Long (> 20 minutes)"/>
|
<ComboBoxItem Content="Long (> 20 minutes)"/>
|
||||||
|
<ComboBoxItem Content="Medium"/>
|
||||||
|
<ComboBoxItem Content="Short (< 4 minutes)"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</GridView>
|
</GridView>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
</Flyout>
|
</Flyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Content="Apply" Margin="10,0,0,10" Click="AppBarButton_Click"/>
|
<Button Content="Apply" Margin="10,0,0,10" Name="apply" Click="apply_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<pages:VideoGrid/>
|
<pages:VideoGrid/>
|
||||||
|
|||||||
+60
-125
@@ -29,8 +29,7 @@ namespace FoxTube
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class Search : Page
|
public sealed partial class Search : Page
|
||||||
{
|
{
|
||||||
public string Term;
|
public SearchParameters Parameters;
|
||||||
string channelId = null;
|
|
||||||
SearchResource.ListRequest request;
|
SearchResource.ListRequest request;
|
||||||
string nextToken;
|
string nextToken;
|
||||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||||
@@ -67,7 +66,7 @@ namespace FoxTube
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "youtube#channel":
|
case "youtube#channel":
|
||||||
if(channelId == null)
|
if(Parameters.Channel == null)
|
||||||
list.Add(new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent));
|
list.Add(new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -85,39 +84,31 @@ namespace FoxTube
|
|||||||
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
|
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (e.Parameter is string)
|
if (e.Parameter is SearchParameters)
|
||||||
Initialize(e.Parameter as string);
|
|
||||||
else if (e.Parameter is SearchParameters)
|
|
||||||
Initialize(e.Parameter as SearchParameters);
|
Initialize(e.Parameter as SearchParameters);
|
||||||
else
|
else
|
||||||
loading.Error("ArgumentException", "Wrong search parameters");
|
loading.Error("ArgumentException", "Wrong parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(SearchParameters arg)
|
public async void Initialize(SearchParameters arg, bool forceInitialization = false)
|
||||||
{
|
{
|
||||||
Initialize(arg.Term, channel: arg.ChannelId);
|
if (Parameters != null && arg.Term == Parameters.Term && !forceInitialization)
|
||||||
}
|
|
||||||
|
|
||||||
public async void Initialize(string term, bool forceInitialization = false, string channel = null)
|
|
||||||
{
|
|
||||||
if (term == Term && !forceInitialization)
|
|
||||||
return;
|
return;
|
||||||
loading.Refresh();
|
loading.Refresh();
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
{
|
||||||
Term = term;
|
Parameters = arg;
|
||||||
request = SecretsVault.Service.Search.List("id,snippet");
|
request = SecretsVault.Service.Search.List("id,snippet");
|
||||||
if (!string.IsNullOrWhiteSpace(channel))
|
if (!string.IsNullOrWhiteSpace(arg.Channel))
|
||||||
{
|
{
|
||||||
channelId = channel;
|
request.ChannelId = arg.Channel;
|
||||||
request.ChannelId = channel;
|
|
||||||
(type.Items[2] as ComboBoxItem).Visibility = Visibility.Collapsed;
|
(type.Items[2] as ComboBoxItem).Visibility = Visibility.Collapsed;
|
||||||
(grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed;
|
(grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
request.Q = term;
|
request.Q = arg.Term;
|
||||||
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
|
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -128,32 +119,36 @@ namespace FoxTube
|
|||||||
request.RelevanceLanguage = settings.Values["region"].ToString().ToLower();
|
request.RelevanceLanguage = settings.Values["region"].ToString().ToLower();
|
||||||
}
|
}
|
||||||
request.MaxResults = 48;
|
request.MaxResults = 48;
|
||||||
request.Order = Order;
|
try
|
||||||
request.Type = Type;
|
|
||||||
request.PublishedAfter = Date;
|
|
||||||
|
|
||||||
if(type.SelectedIndex == 1)
|
|
||||||
{
|
{
|
||||||
request.VideoDuration = Duration;
|
request.Order = (SearchResource.ListRequest.OrderEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.Order);
|
||||||
if (features.SelectedItems.Count > 0)
|
request.Type = (string)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.Type);
|
||||||
{
|
request.PublishedAfter = (DateTime)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.Date);
|
||||||
request.Type = "video";
|
|
||||||
type.SelectedIndex = 1;
|
request.VideoDefinition = (SearchResource.ListRequest.VideoDefinitionEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.HD);
|
||||||
if (features.SelectedItems.Contains(features.Items[0]))
|
request.VideoDimension = (SearchResource.ListRequest.VideoDimensionEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.ThreeD);
|
||||||
request.VideoDefinition = SearchResource.ListRequest.VideoDefinitionEnum.High;
|
request.VideoCaption = (SearchResource.ListRequest.VideoCaptionEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.Captions);
|
||||||
if (features.SelectedItems.Contains(features.Items[1]))
|
request.EventType = (SearchResource.ListRequest.EventTypeEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.LiveEvent);
|
||||||
request.VideoDimension = SearchResource.ListRequest.VideoDimensionEnum.Value3d;
|
request.VideoLicense = (SearchResource.ListRequest.VideoLicenseEnum)arg.Filter.GetParameter(SearchParameters.Filters.Enumerations.ConversionType.CreativeCommons);
|
||||||
if (features.SelectedItems.Contains(features.Items[2]))
|
|
||||||
request.VideoCaption = SearchResource.ListRequest.VideoCaptionEnum.ClosedCaption;
|
|
||||||
if (features.SelectedItems.Contains(features.Items[3]))
|
|
||||||
request.EventType = SearchResource.ListRequest.EventTypeEnum.Live;
|
|
||||||
if (features.SelectedItems.Contains(features.Items[4]))
|
|
||||||
request.VideoLicense = SearchResource.ListRequest.VideoLicenseEnum.CreativeCommon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
order.SelectedIndex = (int)Parameters.Filter.Order;
|
||||||
|
type.SelectedIndex = (int)Parameters.Filter.Type;
|
||||||
|
duration.SelectedIndex = (int)Parameters.Filter.Duration;
|
||||||
|
if (Parameters.Filter.HD)
|
||||||
|
features.SelectedItems.Add(features.Items[0]);
|
||||||
|
if (Parameters.Filter.Is3D)
|
||||||
|
features.SelectedItems.Add(features.Items[1]);
|
||||||
|
if (Parameters.Filter.Captions)
|
||||||
|
features.SelectedItems.Add(features.Items[2]);
|
||||||
|
if (Parameters.Filter.LiveEvent)
|
||||||
|
features.SelectedItems.Add(features.Items[3]);
|
||||||
|
if (Parameters.Filter.CreativeCommons)
|
||||||
|
features.SelectedItems.Add(features.Items[4]);
|
||||||
|
|
||||||
SearchListResponse response = await request.ExecuteAsync();
|
SearchListResponse response = await request.ExecuteAsync();
|
||||||
searchTerm.Text = $"Search results for: {Term}";
|
searchTerm.Text = $"Search results for: {Parameters.Term}";
|
||||||
resultsCount.Text = $"Found: {SetResults(response.PageInfo.TotalResults)} item(s)";
|
resultsCount.Text = $"Found: {SetResults(response.PageInfo.TotalResults)} item(s)";
|
||||||
if (!string.IsNullOrWhiteSpace(response.NextPageToken))
|
if (!string.IsNullOrWhiteSpace(response.NextPageToken))
|
||||||
nextToken = response.NextPageToken;
|
nextToken = response.NextPageToken;
|
||||||
@@ -166,14 +161,14 @@ namespace FoxTube
|
|||||||
|
|
||||||
loading.Close();
|
loading.Close();
|
||||||
}
|
}
|
||||||
catch (System.Net.Http.HttpRequestException)
|
/*catch (System.Net.Http.HttpRequestException)
|
||||||
{
|
{
|
||||||
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 (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
loading.Error(e.GetType().ToString(), e.Message);
|
loading.Error(e.GetType().ToString(), e.Message);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleFilters_Click(object sender, RoutedEventArgs e)
|
private void toggleFilters_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -181,96 +176,18 @@ namespace FoxTube
|
|||||||
if(filters.Visibility == Visibility.Collapsed)
|
if(filters.Visibility == Visibility.Collapsed)
|
||||||
{
|
{
|
||||||
filters.Visibility = Visibility.Visible;
|
filters.Visibility = Visibility.Visible;
|
||||||
toggleFilters.Content = "Hide filters ";
|
toggleFilters.Content = "Hide filters \xE014";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filters.Visibility = Visibility.Collapsed;
|
filters.Visibility = Visibility.Collapsed;
|
||||||
toggleFilters.Content = "Show filters ";
|
toggleFilters.Content = "Show filters \xE015";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchResource.ListRequest.OrderEnum Order
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (order.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return SearchResource.ListRequest.OrderEnum.Date;
|
|
||||||
case 2:
|
|
||||||
return SearchResource.ListRequest.OrderEnum.ViewCount;
|
|
||||||
case 3:
|
|
||||||
return SearchResource.ListRequest.OrderEnum.Rating;
|
|
||||||
case 4:
|
|
||||||
return SearchResource.ListRequest.OrderEnum.Title;
|
|
||||||
default:
|
|
||||||
return SearchResource.ListRequest.OrderEnum.Relevance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string Type
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch(type.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return "video";
|
|
||||||
case 2:
|
|
||||||
return "channel";
|
|
||||||
case 3:
|
|
||||||
return "playlist";
|
|
||||||
default:
|
|
||||||
return "video,channel,playlist";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime? Date
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch(date.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return DateTime.Now.Subtract(TimeSpan.FromHours(1));
|
|
||||||
case 2:
|
|
||||||
return DateTime.Now.Subtract(TimeSpan.FromDays(1));
|
|
||||||
case 3:
|
|
||||||
return DateTime.Now.Subtract(TimeSpan.FromDays(7));
|
|
||||||
case 4:
|
|
||||||
return DateTime.Now.Subtract(TimeSpan.FromDays(31));
|
|
||||||
case 5:
|
|
||||||
return DateTime.Now.Subtract(TimeSpan.FromDays(365));
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchResource.ListRequest.VideoDurationEnum Duration
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (type.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return SearchResource.ListRequest.VideoDurationEnum.Short__;
|
|
||||||
case 2:
|
|
||||||
return SearchResource.ListRequest.VideoDurationEnum.Medium;
|
|
||||||
case 3:
|
|
||||||
return SearchResource.ListRequest.VideoDurationEnum.Long__;
|
|
||||||
default:
|
|
||||||
return SearchResource.ListRequest.VideoDurationEnum.Any;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppBarButton_Click(object sender, RoutedEventArgs e)
|
private void AppBarButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Initialize(Term, true, channelId);
|
Initialize(Parameters, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void more_Clicked()
|
private async void more_Clicked()
|
||||||
@@ -302,6 +219,8 @@ namespace FoxTube
|
|||||||
{
|
{
|
||||||
duration.Visibility = Visibility.Collapsed;
|
duration.Visibility = Visibility.Collapsed;
|
||||||
featBtn.Visibility = Visibility.Collapsed;
|
featBtn.Visibility = Visibility.Collapsed;
|
||||||
|
duration.SelectedIndex = 0;
|
||||||
|
features.SelectedItems.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NullReferenceException) { }
|
catch (NullReferenceException) { }
|
||||||
@@ -311,5 +230,21 @@ namespace FoxTube
|
|||||||
{
|
{
|
||||||
await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/results?search_query={searchTerm}"));
|
await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/results?search_query={searchTerm}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void apply_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Parameters.Filter.HD = features.SelectedItems.Contains(features.Items[0]);
|
||||||
|
Parameters.Filter.Is3D = features.SelectedItems.Contains(features.Items[1]);
|
||||||
|
Parameters.Filter.Captions = features.SelectedItems.Contains(features.Items[2]);
|
||||||
|
Parameters.Filter.LiveEvent = features.SelectedItems.Contains(features.Items[3]);
|
||||||
|
Parameters.Filter.CreativeCommons = features.SelectedItems.Contains(features.Items[4]);
|
||||||
|
|
||||||
|
Parameters.Filter.Order = (SearchParameters.Filters.Enumerations.Order)order.SelectedIndex;
|
||||||
|
Parameters.Filter.Type = (SearchParameters.Filters.Enumerations.Type)type.SelectedIndex;
|
||||||
|
Parameters.Filter.Date = (SearchParameters.Filters.Enumerations.Date)date.SelectedIndex;
|
||||||
|
Parameters.Filter.Duration = (SearchParameters.Filters.Enumerations.Duration)duration.SelectedIndex;
|
||||||
|
|
||||||
|
Methods.MainPage.GoToSearch(Parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
<ComboBoxItem Content="240p"/>
|
<ComboBoxItem Content="240p"/>
|
||||||
<ComboBoxItem Content="144p"/>
|
<ComboBoxItem Content="144p"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<ToggleSwitch x:Uid="/General/metered" OnContent="Notify when playing on metered connection" OffContent="Notify when playing on metered connection" Name="mobileWarning" Toggled="notification_IsEnabledChanged"/>
|
<ToggleSwitch x:Uid="/General/metered" OnContent="Notify when playing on metered connection" OffContent="Notify when playing on metered connection" Name="mobileWarning" Toggled="mobileWarning_Toggled"/>
|
||||||
<ToggleSwitch x:Uid="/General/autoplay" OnContent="Play videos automatically" OffContent="Play videos automatically" Name="autoplay" Toggled="notification_IsEnabledChanged"/>
|
<ToggleSwitch x:Uid="/General/autoplay" OnContent="Play videos automatically" OffContent="Play videos automatically" Name="autoplay" Toggled="autoplay_Toggled"/>
|
||||||
|
|
||||||
<TextBlock x:Uid="/General/notifications" Text="Notifications" FontSize="22"/>
|
<TextBlock x:Uid="/General/notifications" Text="Notifications" FontSize="22"/>
|
||||||
<ToggleSwitch x:Uid="/General/newVideo" Name="newVideo" OnContent="Notify when someone of your subscriptions uploaded new video" OffContent="Notify when someone of your subscriptions uploaded new video" Toggled="notification_IsEnabledChanged"/>
|
<ToggleSwitch x:Uid="/General/newVideo" Name="newVideo" OnContent="Notify when someone of your subscriptions uploaded new video" OffContent="Notify when someone of your subscriptions uploaded new video" Toggled="notification_IsEnabledChanged"/>
|
||||||
|
|||||||
@@ -79,11 +79,20 @@ namespace FoxTube.Pages.SettingsPages
|
|||||||
settings.Values["quality"] = quality.SelectedIndex;
|
settings.Values["quality"] = quality.SelectedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mobileWarning_Toggled(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
settings.Values["moblieWarning"] = mobileWarning.IsOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void autoplay_Toggled(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
settings.Values["videoAutoplay"] = autoplay.IsOn;
|
||||||
|
}
|
||||||
|
|
||||||
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
|
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
settings.Values["newVideoNotification"] = newVideo.IsOn;
|
settings.Values["newVideoNotification"] = newVideo.IsOn;
|
||||||
settings.Values["moblieWarning"] = mobileWarning.IsOn;
|
|
||||||
settings.Values["videoAutoplay"] = autoplay.IsOn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user