Video playback fixes
Merged to YouTubeExplode instead of MyToolkit
This commit is contained in:
@@ -1,73 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using MyToolkit.Multimedia;
|
||||
using Windows.Storage;
|
||||
using FoxTube.Classes;
|
||||
using Newtonsoft.Json;
|
||||
using Windows.UI.Popups;
|
||||
|
||||
namespace FoxTube.Controls
|
||||
{
|
||||
public class DownloadAgent
|
||||
{
|
||||
public List<DownloadItem> Items = new List<DownloadItem>();
|
||||
public event ObjectEventHandler ListChanged;
|
||||
|
||||
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
XmlDocument doc = new XmlDocument();
|
||||
public List<DownloadItem> items = new List<DownloadItem>();
|
||||
StorageFolder roaming = ApplicationData.Current.RoamingFolder;
|
||||
|
||||
public DownloadAgent()
|
||||
{
|
||||
if (settings.Values["downloadHistory"] != null)
|
||||
doc.LoadXml(settings.Values["downloadHistory"] as string);
|
||||
else
|
||||
Initialize();
|
||||
Windows.UI.Core.Preview.SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += (s, a) => QuitPrompt();
|
||||
}
|
||||
|
||||
public async void Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||
doc.AppendChild(doc.CreateElement("downloads"));
|
||||
settings.Values.Add("downloadHistory", doc.InnerXml);
|
||||
List<DownloadItemContainer> containers = JsonConvert.DeserializeObject<List<DownloadItemContainer>>(await FileIO.ReadTextAsync(await roaming.GetFileAsync("data.json")));
|
||||
|
||||
foreach (DownloadItemContainer i in containers)
|
||||
try { items.Add(new DownloadItem(i)); }
|
||||
catch (FileNotFoundException) { }
|
||||
}
|
||||
|
||||
foreach(XmlElement e in doc["downloads"].ChildNodes)
|
||||
try
|
||||
{
|
||||
Items.Add(new DownloadItem(
|
||||
e["details"]["id"].InnerText,
|
||||
e["title"].InnerText,
|
||||
e["snippet"]["author"].InnerText,
|
||||
e["snippet"]["image"].InnerText,
|
||||
e["snippet"]["duration"].InnerText,
|
||||
e["snippet"]["quality"].InnerText,
|
||||
e["details"]["path"].InnerText));
|
||||
}
|
||||
catch { }
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void Add(string id, YouTubeQuality quality)
|
||||
public void Add(string url)
|
||||
{
|
||||
DownloadItem item = new DownloadItem(id, quality);
|
||||
item.DownloadCanceled += Item_DownloadCanceled;
|
||||
item.DownloadComplete += Item_DownloadComplete;
|
||||
|
||||
Items.Add(item);
|
||||
ListChanged.Invoke(item, "add");
|
||||
}
|
||||
|
||||
public void Add(string id, string url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Item_DownloadComplete(object sender, params object[] e)
|
||||
{
|
||||
doc["downloads"].InnerXml += e[0];
|
||||
settings.Values["downloadHistory"] = doc.InnerXml;
|
||||
items.Add(new DownloadItem(url));
|
||||
}
|
||||
|
||||
private void Item_DownloadCanceled(object sender, params object[] e)
|
||||
{
|
||||
Items.Remove(sender as DownloadItem);
|
||||
ListChanged.Invoke(sender, "remove");
|
||||
items.Remove(sender as DownloadItem);
|
||||
}
|
||||
|
||||
public async void QuitPrompt()
|
||||
{
|
||||
if(items.Find(x => x.InProgress) != null)
|
||||
{
|
||||
MessageDialog dialog = new MessageDialog("You have some unfinished downloads. Quitting now will erase all downloaded data. Are you sure to continue?", "Some downloads are still pending");
|
||||
|
||||
dialog.Commands.Add(new UICommand("Yes", async (command) =>
|
||||
{
|
||||
foreach (DownloadItem i in items.FindAll(x => x.InProgress))
|
||||
i.Cancel();
|
||||
items.RemoveAll(x => x.InProgress);
|
||||
|
||||
List<DownloadItemContainer> containers = new List<DownloadItemContainer>();
|
||||
foreach (DownloadItem i in items)
|
||||
containers.Add(i.Container);
|
||||
|
||||
await FileIO.WriteTextAsync(
|
||||
await roaming.CreateFileAsync("data.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(containers));
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("No"));
|
||||
|
||||
dialog.DefaultCommandIndex = 1;
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
|
||||
namespace FoxTube.Classes
|
||||
{
|
||||
public class DownloadItemContainer
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Channel { get; set; }
|
||||
public string Id { get; set; }
|
||||
public Uri Path { get; set; }
|
||||
public Uri Thumbnail { get; set; }
|
||||
public VideoQuality Quality { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using MyToolkit.Multimedia;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.System;
|
||||
@@ -30,6 +26,11 @@ namespace FoxTube
|
||||
CoreApplication.Exit();
|
||||
}
|
||||
|
||||
public static Uri ToUri(this string url)
|
||||
{
|
||||
return new Uri(url);
|
||||
}
|
||||
|
||||
public static string GetAgo(DateTime dateTime)
|
||||
{
|
||||
TimeSpan span = DateTime.Now - dateTime;
|
||||
@@ -105,7 +106,7 @@ namespace FoxTube
|
||||
}
|
||||
}
|
||||
|
||||
public static string QualityToString(YouTubeQuality quality)
|
||||
/*public static string QualityToString(YouTubeQuality quality)
|
||||
{
|
||||
switch(quality)
|
||||
{
|
||||
@@ -138,7 +139,7 @@ namespace FoxTube
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public async static void ProcessLink(string url)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<TextBlock Text="Author:" Foreground="Gray" Name="channel"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Name="donePanel" Grid.Column="3" Orientation="Horizontal" Visibility="Collapsed">
|
||||
<StackPanel Name="donePanel" Grid.Column="3" Orientation="Horizontal" Visibility="Visible">
|
||||
<Button Name="open" Click="open_Click" Width="80" Height="80" Padding="0" Background="Transparent">
|
||||
<StackPanel>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="30" HorizontalAlignment="Center"/>
|
||||
|
||||
@@ -1,26 +1,12 @@
|
||||
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;
|
||||
using System.Net;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.System;
|
||||
using MyToolkit.Multimedia;
|
||||
using Windows.Storage;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using Windows.UI.Popups;
|
||||
using System.Xml;
|
||||
using FoxTube.Classes;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -28,55 +14,36 @@ namespace FoxTube.Controls
|
||||
{
|
||||
public sealed partial class DownloadItem : UserControl
|
||||
{
|
||||
string uri;
|
||||
string Id;
|
||||
public DownloadItemContainer Container { get; private set; }
|
||||
public bool InProgress { get; set; } = false;
|
||||
|
||||
public DownloadItem(string url)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Download(url);
|
||||
}
|
||||
|
||||
public event ObjectEventHandler DownloadCanceled;
|
||||
public event ObjectEventHandler DownloadComplete;
|
||||
|
||||
WebClient client = new WebClient();
|
||||
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
public DownloadItem(string id, YouTubeQuality q)
|
||||
public DownloadItem(DownloadItemContainer container)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
client.DownloadFileCompleted += DownloadCompleted;
|
||||
client.DownloadProgressChanged += UpdateInfo;
|
||||
Container = container;
|
||||
if (!File.Exists(container.Path.AbsolutePath))
|
||||
throw new FileNotFoundException();
|
||||
|
||||
title.Text = Container.Title;
|
||||
thumbnail.Source = new BitmapImage(Container.Thumbnail);
|
||||
quality.Text = $"Quality: {Container.Quality.GetVideoQualityLabel()}";
|
||||
duration.Text = $"Duration: {Container.Duration}";
|
||||
channel.Text = $"Author: {Container.Channel}";
|
||||
|
||||
progressPanel.Visibility = Visibility.Collapsed;
|
||||
donePanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
async void Download(string id, YouTubeQuality q)
|
||||
void Download(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
Id = id;
|
||||
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet");
|
||||
request.Id = id;
|
||||
var response = (await request.ExecuteAsync()).Items[0];
|
||||
|
||||
Uri url = (await YouTube.GetVideoUriAsync(id, q)).Uri;
|
||||
|
||||
client.DownloadFileAsync(url, settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4");
|
||||
|
||||
thumbnail.Source = new BitmapImage(new Uri(response.Snippet.Thumbnails.Standard.Url));
|
||||
title.Text = response.Snippet.Title;
|
||||
channel.Text = $"Author: {response.Snippet.ChannelTitle}";
|
||||
|
||||
quality.Text = $"Quality: {Methods.QualityToString(q)}"; TimeSpan ts = XmlConvert.ToTimeSpan(response.ContentDetails.Duration);
|
||||
duration.Text = string.Format("Duration: {0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds);
|
||||
|
||||
uri = settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4";
|
||||
|
||||
status.Text = "Downloading...";
|
||||
perc.Text = "0%";
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (client.IsBusy)
|
||||
client.CancelAsync();
|
||||
await new MessageDialog("We were unable to download video due to connection problems or internal YouTube server error. Please, try again later.", "Failed to download").ShowAsync();
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void UpdateInfo(object sender, DownloadProgressChangedEventArgs e)
|
||||
@@ -87,7 +54,7 @@ namespace FoxTube.Controls
|
||||
|
||||
private void DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
|
||||
{
|
||||
progressPanel.Visibility = Visibility.Collapsed;
|
||||
/*progressPanel.Visibility = Visibility.Collapsed;
|
||||
donePanel.Visibility = Visibility.Visible;
|
||||
|
||||
string node = $@"<item>
|
||||
@@ -103,41 +70,27 @@ namespace FoxTube.Controls
|
||||
</details>
|
||||
</item>";
|
||||
|
||||
DownloadComplete.Invoke(this, node);
|
||||
}
|
||||
|
||||
public DownloadItem(string videoId, string videoName, string channelName, string thumbUrl, string length, string videoQuality, string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
throw new FileNotFoundException();
|
||||
|
||||
title.Text = videoName;
|
||||
thumbnail.Source = new BitmapImage(new Uri(thumbUrl));
|
||||
quality.Text = $"Quality: {videoQuality}";
|
||||
duration.Text = $"Duration: {length}";
|
||||
channel.Text = $"Author: {channelName}";
|
||||
|
||||
progressPanel.Visibility = Visibility.Collapsed;
|
||||
donePanel.Visibility = Visibility.Visible;
|
||||
|
||||
uri = path;
|
||||
Id = videoId;
|
||||
DownloadComplete.Invoke(this, node);*/
|
||||
}
|
||||
|
||||
private async void open_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(uri))
|
||||
await Launcher.LaunchUriAsync(new Uri(uri));
|
||||
await Launcher.LaunchUriAsync(Container.Path);
|
||||
}
|
||||
|
||||
private void gotoOriginal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.GoToVideo(Id);
|
||||
Methods.MainPage.GoToVideo(Container.Id);
|
||||
}
|
||||
|
||||
private async void cancel_Click(object sender, RoutedEventArgs e)
|
||||
public void Cancel()
|
||||
{
|
||||
if(client.IsBusy)
|
||||
|
||||
}
|
||||
|
||||
private void cancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
/*if(client.IsBusy)
|
||||
{
|
||||
MessageDialog dialog = new MessageDialog("Are you sure?", "Cancelling download");
|
||||
|
||||
@@ -153,7 +106,7 @@ namespace FoxTube.Controls
|
||||
|
||||
dialog.DefaultCommandIndex = 1;
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,16 +123,7 @@
|
||||
<Button Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Width="50" Height="50" FontSize="25" ToolTipService.ToolTip="Video quality">
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<ComboBox Width="225" Header="Quality" Name="quality" SelectionChanged="quality_SelectionChanged">
|
||||
<!--<ComboBoxItem Content="Auto"/>-->
|
||||
<ComboBoxItem Content="2160P" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="1080p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="720p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="480p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="360p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="240p" Visibility="Collapsed"/>
|
||||
<ComboBoxItem Content="144p" Visibility="Collapsed"/>
|
||||
</ComboBox>
|
||||
<ComboBox Width="225" Header="Quality" Name="quality" SelectionChanged="quality_SelectionChanged"/>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Timers;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Core;
|
||||
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;
|
||||
using Microsoft.Toolkit.Uwp.UI.Animations;
|
||||
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.Networking.Connectivity;
|
||||
using System.Diagnostics;
|
||||
using Windows.Media;
|
||||
using Windows.Storage.Streams;
|
||||
@@ -28,17 +19,13 @@ using Windows.UI.ViewManagement;
|
||||
using System.Xml;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.UI;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.Media.Casting;
|
||||
using MyToolkit.Multimedia;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
using YoutubeExplode;
|
||||
using YoutubeExplode.Models.ClosedCaptions;
|
||||
using System.Globalization;
|
||||
using FoxTube.Controls;
|
||||
using Windows.System;
|
||||
using Windows.Devices.Sensors;
|
||||
using Windows.System.Profile;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -87,7 +74,7 @@ namespace FoxTube
|
||||
LiveCaptions captions;
|
||||
|
||||
IReadOnlyList<ClosedCaptionTrackInfo> ccInfo;
|
||||
List<YouTubeUri> streamInfo;
|
||||
MediaStreamInfoSet streamInfo;
|
||||
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
Timer t = new Timer()
|
||||
@@ -132,35 +119,25 @@ namespace FoxTube
|
||||
|
||||
#region Retrieving info for CC and Media streams
|
||||
//Loading streams
|
||||
streamInfo = (await YouTube.GetUrisAsync(item.Id)).ToList();
|
||||
foreach (YouTubeQuality q in Enum.GetValues(typeof(YouTubeQuality)))
|
||||
if (streamInfo.FindAll(x => x.VideoQuality == q).Count > 1)
|
||||
streamInfo.RemoveAll(x => x.VideoQuality == q && !x.HasAudio);
|
||||
streamInfo = await new YoutubeClient().GetVideoMediaStreamInfosAsync(videoId);
|
||||
streamInfo.Audio.ToList().ForEach(x => Debug.WriteLine($"{x.AudioEncoding} {x.Bitrate}"));
|
||||
|
||||
streamInfo.ForEach(x => Debug.WriteLine($"{x.HasAudio}; {x.HasVideo}; {x.VideoQuality}; {x.AudioQuality}"));
|
||||
foreach (YouTubeUri i in streamInfo)
|
||||
{
|
||||
if (i.VideoQuality == YouTubeQuality.Quality2160P)
|
||||
(quality.Items[0] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality1080P)
|
||||
(quality.Items[1] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality720P)
|
||||
(quality.Items[2] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality480P)
|
||||
(quality.Items[3] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality360P)
|
||||
(quality.Items[4] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality240P)
|
||||
(quality.Items[5] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
if (i.VideoQuality == YouTubeQuality.Quality144P)
|
||||
(quality.Items[6] as ComboBoxItem).Visibility = Visibility.Visible;
|
||||
}
|
||||
List<VideoQuality> q = streamInfo.GetAllVideoQualities().ToList();
|
||||
q.Sort();
|
||||
q.Reverse();
|
||||
foreach (VideoQuality i in q)
|
||||
quality.Items.Add(new ComboBoxItem() { Content = i.GetVideoQualityLabel() });
|
||||
|
||||
int k = (int)settings.Values["quality"];
|
||||
if ((quality.Items[k] as ComboBoxItem).Visibility == Visibility.Visible)
|
||||
quality.SelectedIndex = k;
|
||||
string s;
|
||||
if ((string)settings.Values["quality"] == "remember")
|
||||
s = (string)settings.Values["rememberedQuality"];
|
||||
else
|
||||
quality.SelectedItem = quality.Items.First(x => (x as ComboBoxItem).Visibility == Visibility.Visible);
|
||||
s = (string)settings.Values["quality"];
|
||||
|
||||
if (quality.Items.ToList().Find(x => (x as ComboBoxItem).Content as string == s) != null)
|
||||
quality.SelectedItem = quality.Items.First(x => (x as ComboBoxItem).Content as string == s);
|
||||
else
|
||||
quality.SelectedItem = quality.Items.First();
|
||||
|
||||
//Loading captions
|
||||
ccInfo = await new YoutubeClient().GetVideoClosedCaptionTrackInfosAsync(item.Id);
|
||||
@@ -369,11 +346,28 @@ namespace FoxTube
|
||||
audioReady = false;
|
||||
videoReady = false;
|
||||
|
||||
switch((quality.SelectedItem as ComboBoxItem).Content)
|
||||
settings.Values["rememberedQuality"] = (quality.SelectedItem as ComboBoxItem).Content as string;
|
||||
|
||||
if(streamInfo.Muxed.ToList().Find(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string) != null)
|
||||
{
|
||||
isMuxed = true;
|
||||
videoSource.Source = streamInfo.Muxed.First(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string).Url.ToUri();
|
||||
}
|
||||
else
|
||||
{
|
||||
isMuxed = false;
|
||||
videoSource.Source = streamInfo.Video.First(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string).Url.ToUri();
|
||||
audioSource.Source = streamInfo.Audio.First().Url.ToUri();
|
||||
}
|
||||
|
||||
/*switch((quality.SelectedItem as ComboBoxItem).Content)
|
||||
{
|
||||
case "2160p":
|
||||
if(streamInfo.First(x => x.VideoQuality == YouTubeQuality.Quality2160P).HasAudio)
|
||||
if(streamInfo.Muxed.First(x => x.VideoQuality.))
|
||||
{
|
||||
isMuxed = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
isMuxed = false;
|
||||
@@ -456,7 +450,7 @@ namespace FoxTube
|
||||
}
|
||||
videoSource.Source = streamInfo.First(x => x.VideoQuality == YouTubeQuality.Quality144P).Uri;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
needUpdateTimecode = true;
|
||||
videoSource.Play();
|
||||
|
||||
+13
-12
@@ -97,6 +97,7 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Classes\Caption.cs" />
|
||||
<Compile Include="Classes\DownloadItemContainer.cs" />
|
||||
<Compile Include="Classes\InboxItem.cs" />
|
||||
<Compile Include="Classes\Methods.cs" />
|
||||
<Compile Include="Classes\ObjectEventArgs.cs" />
|
||||
@@ -398,7 +399,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AdaptiveCards.Rendering.Uwp">
|
||||
<Version>1.0.1</Version>
|
||||
<Version>1.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Google.Apis">
|
||||
<Version>1.30.0-beta02</Version>
|
||||
@@ -419,25 +420,25 @@
|
||||
<Version>10.1805.7001</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.1.5</Version>
|
||||
<Version>6.1.9</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
||||
<Version>3.0.0</Version>
|
||||
<Version>4.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
<Version>3.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MyToolkit">
|
||||
<Version>2.5.16</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MyToolkit.Extended">
|
||||
<Version>2.5.16</Version>
|
||||
<Version>4.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
|
||||
<Version>4.3.1</Version>
|
||||
<Version>4.3.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Syroot.Windows.IO.KnownFolders">
|
||||
<Version>1.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="YoutubeExplode">
|
||||
<Version>4.3.1</Version>
|
||||
<Version>4.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="YoutubeExtractor">
|
||||
<Version>0.10.11</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:local="using:FoxTube.Pages"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:FoxTube.Controls"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
@@ -27,7 +28,9 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel Margin="5" Name="stack"/>
|
||||
<StackPanel Margin="5" Name="stack">
|
||||
<ListView ItemsSource="{Binding Path=Methods.MainPage.agent.items}" SelectionMode="None"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -11,11 +11,6 @@ using Windows.Storage.Pickers;
|
||||
using Windows.System;
|
||||
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
|
||||
#pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast
|
||||
@@ -28,33 +23,20 @@ namespace FoxTube.Pages
|
||||
public sealed partial class Downloads : Page
|
||||
{
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
DownloadAgent agent = Methods.MainPage.Agent;
|
||||
public Downloads()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
path.Text = settings.Values["defaultDownload"] as string;
|
||||
|
||||
agent.ListChanged += UpdateList;
|
||||
|
||||
foreach (DownloadItem item in agent.Items)
|
||||
stack.Children.Add(item);
|
||||
}
|
||||
|
||||
private void UpdateList(object sender, params object[] e)
|
||||
{
|
||||
if (e[0] == "remove")
|
||||
stack.Children.Remove(sender as DownloadItem);
|
||||
else if (e[0] == "add")
|
||||
stack.Children.Add(sender as DownloadItem);
|
||||
}
|
||||
|
||||
private async void changePath_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker()
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.Desktop,
|
||||
SuggestedStartLocation = PickerLocationId.Downloads,
|
||||
ViewMode = PickerViewMode.Thumbnail
|
||||
};
|
||||
picker.FileTypeFilter.Add(".shit"); //Because overwise it trhows an exception
|
||||
|
||||
StorageFolder p = await picker.PickSingleFolderAsync();
|
||||
if (p != null)
|
||||
@@ -64,7 +46,7 @@ namespace FoxTube.Pages
|
||||
|
||||
private async void openFolder_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri(settings.Values["defaultDownload"] as string));
|
||||
await Launcher.LaunchFolderAsync( await StorageFolder.GetFolderFromPathAsync(settings.Values["defaultDownload"] as string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Net;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Networking.Connectivity;
|
||||
using Windows.UI.Core;
|
||||
using Syroot.Windows.IO;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
@@ -48,7 +49,9 @@ namespace FoxTube
|
||||
this.InitializeComponent();
|
||||
|
||||
if (settings.Values["quality"] == null)
|
||||
settings.Values.Add("quality", 1);
|
||||
settings.Values.Add("quality", "remember");
|
||||
if (settings.Values["rememberedQuality"] == null)
|
||||
settings.Values.Add("rememberedQuality", "1080p");
|
||||
|
||||
if (settings.Values["newVideoNotification"] == null)
|
||||
settings.Values.Add("newVideoNotification", true);
|
||||
@@ -70,7 +73,7 @@ namespace FoxTube
|
||||
settings.Values.Add("safeSearch", 0);
|
||||
|
||||
if (settings.Values["defaultDownload"] == null)
|
||||
settings.Values.Add("defaultDownload", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DownloadedVideos");
|
||||
settings.Values.Add("defaultDownload", Syroot.Windows.IO.KnownFolders.Downloads.Path + "\\DownloadedVideos");
|
||||
|
||||
if (settings.Values["notificationsHistory"] == null)
|
||||
{
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
|
||||
<TextBlock x:Uid="/General/playback" Text="Playback" FontSize="22"/>
|
||||
<ComboBox x:Uid="/General/quality" Width="250" Header="Default video playback quality" Name="quality" SelectionChanged="quality_SelectionChanged">
|
||||
<ComboBoxItem x:Uid="/General/remember" Content="Remember my choice"/>
|
||||
<ComboBoxItem Content="2160p"/>
|
||||
<ComboBoxItem Content="1080p"/>
|
||||
<ComboBoxItem Content="720p"/>
|
||||
<ComboBoxItem Content="480p"/>
|
||||
<ComboBoxItem Content="360p"/>
|
||||
<ComboBoxItem Content="240p"/>
|
||||
<ComboBoxItem Content="144p"/>
|
||||
<ComboBoxItem Tag="remember" x:Uid="/General/remember" Content="Remember my choice"/>
|
||||
<ComboBoxItem Tag="2160p" Content="2160p"/>
|
||||
<ComboBoxItem Tag="1080p" Content="1080p"/>
|
||||
<ComboBoxItem Tag="720p" Content="720p"/>
|
||||
<ComboBoxItem Tag="480p" Content="480p"/>
|
||||
<ComboBoxItem Tag="360p" Content="360p"/>
|
||||
<ComboBoxItem Tag="240p" Content="240p"/>
|
||||
<ComboBoxItem Tag="144p" Content="144p"/>
|
||||
</ComboBox>
|
||||
<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="autoplay_Toggled"/>
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace FoxTube.Pages.SettingsPages
|
||||
|
||||
private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
settings.Values["quality"] = quality.SelectedIndex;
|
||||
settings.Values["quality"] = (quality.SelectedItem as ComboBoxItem).Tag as string;
|
||||
}
|
||||
|
||||
private void mobileWarning_Toggled(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -1,36 +1,21 @@
|
||||
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;
|
||||
using Windows.System;
|
||||
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using System.Diagnostics;
|
||||
using System.Timers;
|
||||
using Windows.UI.Core;
|
||||
using System.Threading;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.Storage;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI;
|
||||
using FoxTube.Pages;
|
||||
|
||||
using MyToolkit.Multimedia;
|
||||
using FoxTube.Controls;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
@@ -250,7 +235,7 @@ namespace FoxTube.Pages
|
||||
|
||||
async void LoadDownloads()
|
||||
{
|
||||
List<YouTubeUri> uris = (await YouTube.GetUrisAsync(item.Id)).ToList();
|
||||
/*List<YouTubeUri> uris = (await YouTube.GetUrisAsync(item.Id)).ToList();
|
||||
if (uris.Count > 0)
|
||||
foreach (YouTubeUri u in uris)
|
||||
{
|
||||
@@ -276,12 +261,12 @@ namespace FoxTube.Pages
|
||||
}
|
||||
}
|
||||
else
|
||||
download.Visibility = Visibility.Collapsed;
|
||||
download.Visibility = Visibility.Collapsed;*/
|
||||
}
|
||||
|
||||
private void downloadItemSelected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.Agent.Add(videoId, (sender as MenuFlyoutItem).Tag.ToString());
|
||||
Methods.MainPage.Agent.Add((sender as MenuFlyoutItem).Tag.ToString());
|
||||
}
|
||||
|
||||
async void LoadRelatedVideos()
|
||||
|
||||
Reference in New Issue
Block a user