#181: Fixed
This commit is contained in:
@@ -22,5 +22,12 @@ namespace FoxTube.Classes
|
||||
Duration = TimeSpan.FromMilliseconds(duration);
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public Caption(double startTime, double duration, string text)
|
||||
{
|
||||
Start = TimeSpan.FromSeconds(startTime);
|
||||
Duration = TimeSpan.FromSeconds(duration);
|
||||
Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,15 +58,18 @@ namespace FoxTube.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(string source)
|
||||
public void Initialize(string source, bool isAutoGenerated = false)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(source);
|
||||
|
||||
if (!isAutoGenerated)
|
||||
foreach (XmlElement i in doc["timedtext"]["body"].ChildNodes)
|
||||
captions.Add(new Caption(int.Parse(i.GetAttribute("t")), int.Parse(i.GetAttribute("d")), i.InnerText));
|
||||
else
|
||||
foreach (XmlElement i in doc["transcript"].ChildNodes)
|
||||
captions.Add(new Caption(double.Parse(i.GetAttribute("start")), double.Parse(i.GetAttribute("dur")), i.InnerText.Replace("<font color=\"#E5E5E5\">", "").Replace("<font color=\"#CCCCCC\">", "").Replace("</font>", "").Replace("'", "'")));
|
||||
|
||||
if(!isClosed)
|
||||
captions.ForEach((x) =>
|
||||
{
|
||||
if (Player.Position > x.Start && Player.Position < x.End)
|
||||
|
||||
@@ -30,11 +30,13 @@ 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;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -152,11 +154,13 @@ namespace FoxTube
|
||||
//Loading captions
|
||||
ccInfo = await client.GetVideoClosedCaptionTrackInfosAsync(item.Id);
|
||||
foreach (ClosedCaptionTrackInfo cc in ccInfo)
|
||||
{
|
||||
subsLang.Items.Add(new ComboBoxItem()
|
||||
{
|
||||
Content = string.Format("{1}{0}", CultureInfo.GetCultureInfo(cc.Language.Code).DisplayName, cc.IsAutoGenerated ? " (Auto-generated)" : ""),
|
||||
Content = string.Format("{0}{1}", CultureInfo.GetCultureInfo(cc.Language.Code).DisplayName, cc.IsAutoGenerated ? " (Auto-generated)" : ""),
|
||||
Tag = cc
|
||||
});
|
||||
}
|
||||
if(ccInfo.Count > 0)
|
||||
subsLang.SelectedIndex = 0;
|
||||
else
|
||||
@@ -393,7 +397,9 @@ namespace FoxTube
|
||||
{
|
||||
if (subsSwitch.IsOn)
|
||||
{
|
||||
|
||||
if (ccInfo[subsLang.SelectedIndex].IsAutoGenerated)
|
||||
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url.Replace("format=3", "format=0"), true);
|
||||
else
|
||||
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url);
|
||||
}
|
||||
else
|
||||
@@ -703,15 +709,15 @@ namespace FoxTube
|
||||
{
|
||||
switch(e.Key)
|
||||
{
|
||||
case Windows.System.VirtualKey.Escape:
|
||||
case Windows.System.VirtualKey.F11:
|
||||
case VirtualKey.Escape:
|
||||
case VirtualKey.F11:
|
||||
if (fullScreen)
|
||||
fullscreen_Click(this, null);
|
||||
break;
|
||||
case Windows.System.VirtualKey.Space:
|
||||
case VirtualKey.Space:
|
||||
play_Click(this, null);
|
||||
break;
|
||||
case Windows.System.VirtualKey.Left:
|
||||
case VirtualKey.Left:
|
||||
back10_Click(this, null);
|
||||
break;
|
||||
case Windows.System.VirtualKey.Right:
|
||||
@@ -722,8 +728,7 @@ namespace FoxTube
|
||||
|
||||
private void subsLang_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (subsSwitch.IsOn)
|
||||
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url);
|
||||
LoadTrack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user