#181: Fixed
This commit is contained in:
@@ -22,5 +22,12 @@ namespace FoxTube.Classes
|
|||||||
Duration = TimeSpan.FromMilliseconds(duration);
|
Duration = TimeSpan.FromMilliseconds(duration);
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Caption(double startTime, double duration, string text)
|
||||||
|
{
|
||||||
|
Start = TimeSpan.FromSeconds(startTime);
|
||||||
|
Duration = TimeSpan.FromSeconds(duration);
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,24 +58,27 @@ namespace FoxTube.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(string source)
|
public void Initialize(string source, bool isAutoGenerated = false)
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(source);
|
doc.Load(source);
|
||||||
|
|
||||||
foreach (XmlElement i in doc["timedtext"]["body"].ChildNodes)
|
if (!isAutoGenerated)
|
||||||
captions.Add(new Caption(int.Parse(i.GetAttribute("t")), int.Parse(i.GetAttribute("d")), i.InnerText));
|
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) =>
|
||||||
captions.ForEach((x) =>
|
{
|
||||||
|
if (Player.Position > x.Start && Player.Position < x.End)
|
||||||
{
|
{
|
||||||
if(Player.Position > x.Start && Player.Position < x.End)
|
currentCaption = x;
|
||||||
{
|
text.Text = currentCaption.Text;
|
||||||
currentCaption = x;
|
Visibility = Visibility.Visible;
|
||||||
text.Text = currentCaption.Text;
|
}
|
||||||
Visibility = Visibility.Visible;
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
timer.Start();
|
timer.Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ 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 MyToolkit.Multimedia;
|
||||||
using YoutubeExplode.Models.MediaStreams;
|
using YoutubeExplode.Models.MediaStreams;
|
||||||
using YoutubeExplode;
|
using YoutubeExplode;
|
||||||
using YoutubeExplode.Models.ClosedCaptions;
|
using YoutubeExplode.Models.ClosedCaptions;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using FoxTube.Controls;
|
using FoxTube.Controls;
|
||||||
|
using Windows.System;
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@@ -152,11 +154,13 @@ namespace FoxTube
|
|||||||
//Loading captions
|
//Loading captions
|
||||||
ccInfo = await client.GetVideoClosedCaptionTrackInfosAsync(item.Id);
|
ccInfo = await client.GetVideoClosedCaptionTrackInfosAsync(item.Id);
|
||||||
foreach (ClosedCaptionTrackInfo cc in ccInfo)
|
foreach (ClosedCaptionTrackInfo cc in ccInfo)
|
||||||
|
{
|
||||||
subsLang.Items.Add(new ComboBoxItem()
|
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
|
Tag = cc
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if(ccInfo.Count > 0)
|
if(ccInfo.Count > 0)
|
||||||
subsLang.SelectedIndex = 0;
|
subsLang.SelectedIndex = 0;
|
||||||
else
|
else
|
||||||
@@ -393,8 +397,10 @@ namespace FoxTube
|
|||||||
{
|
{
|
||||||
if (subsSwitch.IsOn)
|
if (subsSwitch.IsOn)
|
||||||
{
|
{
|
||||||
|
if (ccInfo[subsLang.SelectedIndex].IsAutoGenerated)
|
||||||
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url);
|
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url.Replace("format=3", "format=0"), true);
|
||||||
|
else
|
||||||
|
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
captions.Close();
|
captions.Close();
|
||||||
@@ -703,15 +709,15 @@ namespace FoxTube
|
|||||||
{
|
{
|
||||||
switch(e.Key)
|
switch(e.Key)
|
||||||
{
|
{
|
||||||
case Windows.System.VirtualKey.Escape:
|
case VirtualKey.Escape:
|
||||||
case Windows.System.VirtualKey.F11:
|
case VirtualKey.F11:
|
||||||
if (fullScreen)
|
if (fullScreen)
|
||||||
fullscreen_Click(this, null);
|
fullscreen_Click(this, null);
|
||||||
break;
|
break;
|
||||||
case Windows.System.VirtualKey.Space:
|
case VirtualKey.Space:
|
||||||
play_Click(this, null);
|
play_Click(this, null);
|
||||||
break;
|
break;
|
||||||
case Windows.System.VirtualKey.Left:
|
case VirtualKey.Left:
|
||||||
back10_Click(this, null);
|
back10_Click(this, null);
|
||||||
break;
|
break;
|
||||||
case Windows.System.VirtualKey.Right:
|
case Windows.System.VirtualKey.Right:
|
||||||
@@ -722,8 +728,7 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void subsLang_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void subsLang_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (subsSwitch.IsOn)
|
LoadTrack();
|
||||||
captions.Initialize(ccInfo[subsLang.SelectedIndex].Url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user