Windows phone 8 如何从独立存储中打开Media Player WebVTT标题

Windows phone 8 如何从独立存储中打开Media Player WebVTT标题,windows-phone-8,media-player,isolatedstorage,subtitle,webvtt,Windows Phone 8,Media Player,Isolatedstorage,Subtitle,Webvtt,我在WP8C上有mp4+vtt字幕视频播放器项目。我在看Microsoft.PlayerFramework.MediaPlayer和WebVTTPlugin,它的作品非常完美: 我使用这个代码,工作完美。但我的项目运气不好。vtt标题文件有“,”小数分隔符,这意味着我的应用程序chrash我需要下载字幕并替换所有“,”到“,”并保存独立存储,我处理它,但我无法将标题源设置为独立存储,因为独立存储没有uri。我知道我说不好,我举个例子: 我的说明: () 一, 00:00:06,600 --> 0

我在WP8C上有mp4+vtt字幕视频播放器项目。我在看Microsoft.PlayerFramework.MediaPlayer和WebVTTPlugin,它的作品非常完美: 我使用这个代码,工作完美。但我的项目运气不好。vtt标题文件有“,”小数分隔符,这意味着我的应用程序chrash我需要下载字幕并替换所有“,”到“,”并保存独立存储,我处理它,但我无法将标题源设置为独立存储,因为独立存储没有uri。我知道我说不好,我举个例子:

我的说明: ()

一, 00:00:06,600 --> 00:00:10,900 梅哈巴。Benim adım Charles Bartowski, 阿玛·巴纳·查克·迪耶比利尼兹

二, 00:00:11,323 --> 00:00:12,711 本拉尔·贝尼姆·阿亚卡布·拉尔·姆

三, 00:00:12,771 --> 00:00:14,209 布达贝尼姆·哈亚特先生

四, 00:00:14,249 --> 00:00:19,042 卡斯拉尔、阿拉巴·塔基普勒里、比尔吉萨亚尔 çalan ninjalar ve günükurtaran ben

它的真实标题是:

WEBVTT文件 1. 00:00:06.600-->00:00:10.900默哈巴。贝尼姆·阿德姆 查尔斯·巴托夫斯基,阿玛·巴纳·查克·迪耶比利尼兹

2 00:00:11.323-->00:00:12.711本拉尔·贝尼姆·阿亚卡布·拉尔·拉姆

3 00:00:12.771-->00:00:14.209 Bu da benim hayatım

4 00:00:14.249-->00:00:19.042卡苏斯拉,阿拉巴·塔基普勒里,比尔吉萨亚尔 çalan ninjalar ve günükurtaran ben

代码是:

using Microsoft.PlayerFramework.WebVTT;
using System.IO.IsolatedStorage;
using System.IO;
using System.Threading.Tasks;
using Microsoft.PlayerFramework;

namespace PanoramaApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public string alinanveri="";
        public MainPage()
        {
            InitializeComponent();              

            Microsoft.PlayerFramework.MediaPlayer player =new Microsoft.PlayerFramework.MediaPlayer(); 
            Microsoft.PlayerFramework.WebVTT.WebVTTPlugin webvttPlugin = new WebVTTPlugin();
            Microsoft.PlayerFramework.Caption caption = new Microsoft.PlayerFramework.Caption(); 
            player.IsCaptionSelectionVisible = true;  
            player.Plugins.Add(webvttPlugin);
            altyazikaydet("http://dizilab.com/captions/chuck/sezon-1/tr/2.vtt?v=5.2");
            IsolatedStorageFile kayitliDepo = IsolatedStorageFile.GetUserStoreForApplication();

            var okuyucu = new StreamReader(new IsolatedStorageFileStream("altyazi.vtt", FileMode.Open, kayitliDepo));
            caption.Source = new Uri("i cant use here for access isostorage"); // url points to sample.vtt file

            caption.Description = "Türkçe";            
            player.AvailableCaptions.Add(caption);
            player.SelectedCaption = player.AvailableCaptions.FirstOrDefault();
            LayoutRoot.Children.Add(player);

             player.Source = new Uri("https://redirector.googlevideo.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=eafe5f42d368b2e0&itag=18&source=picasa&cmo=secure_transport%3Dyes&ip=0.0.0.0&ipbits=0&expire=1420976098&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=6E257266C2AAADDFC3260B0AADE603F7E421E130.A933FF8365247DEC72A34B71B02FA3B13C57F291&key=lh1", UriKind.RelativeOrAbsolute); // url points to sample.mp4 fil
        }

        private  async void altyazikaydet(string altyaziurl)
        {
            try
            {

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(altyaziurl);


            using (var response = (HttpWebResponse)(await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null)))
            {
                using (var responseStream = response.GetResponseStream())
                {
                    using (var sr = new StreamReader(responseStream))
                    {

                        alinanveri = await sr.ReadToEndAsync();
                    }
                }
            }
                IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
                StreamWriter yazici = new StreamWriter(new IsolatedStorageFileStream("altyazi.vtt", FileMode.Create, file));

                string x=alinanveri;
                x=x.Replace(",0",".0");
                x=x.Replace(",1",".1");
                x=x.Replace(",2",".2");
                x=x.Replace(",3",".3");
                x=x.Replace(",4",".4");
                x=x.Replace(",5",".5");
                x=x.Replace(",6",".6");
                x=x.Replace(",7",".7");
                x=x.Replace(",8",".8");
                x=x.Replace(",9",".9");
                x = "WEBVTT FILE" + Environment.NewLine + x;
                yazici.WriteLine(x);                
                yazici.Close();
                IsolatedStorageFile kayitliDepo = IsolatedStorageFile.GetUserStoreForApplication();

                StreamReader okuyucu = new StreamReader(new IsolatedStorageFileStream("altyazi.vtt", FileMode.Open, kayitliDepo));

                    string line;
                    while ((line = okuyucu.ReadLine()) != null)
                    {
                        MessageBox.Show(line);
                    }



            }
            catch
            {

            }
        }
使用Microsoft.PlayerFramework.WebVTT;
使用System.IO.IsolatedStorage;
使用System.IO;
使用System.Threading.Tasks;
使用Microsoft.PlayerFramework;
名称空间全景APP1
{
公共部分类主页:PhoneApplicationPage
{
//建造师
公共字符串alinanveri=“”;
公共主页()
{
初始化组件();
Microsoft.PlayerFramework.MediaPlayer=新的Microsoft.PlayerFramework.MediaPlayer();
Microsoft.PlayerFramework.WebVTT.WebVTTPlugin WebVTTPlugin=新的WebVTTPlugin();
Microsoft.PlayerFramework.Caption Caption=新的Microsoft.PlayerFramework.Caption();
player.IsCaptionSelectionVisible=true;
player.Plugins.Add(webvttPlugin);
阿尔蒂亚齐凯代特(”http://dizilab.com/captions/chuck/sezon-1/tr/2.vtt?v=5.2");
IsolatedStorageFile kayitliDepo=IsolatedStorageFile.GetUserStoreForApplication();
var okuyucu=新的StreamReader(新的隔离存储文件流(“altyazi.vtt”,FileMode.Open,kayitliDepo));
caption.Source=newURI(“我不能在这里访问isostorage”);//url指向sample.vtt文件
Description.Description=“Türkçe”;
player.availableOptions.Add(标题);
player.SelectedCaption=player.availableOptions.FirstOrDefault();
LayoutRoot.Children.Add(player);
player.Source=新Uri("https://redirector.googlevideo.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=eafe5f42d368b2e0&itag=18&source=picasa&cmo=secure_transport%3Dyes&ip=0.0.0.0&ipbits=0&expire=1420976098&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbit,expire&signature=6E257266C2AAADDFC3260B0AADE603F7E421E130.A933FF8365247DEC72A34B71B02FA3B13C57F291&key=lh1“,UriKind.RelativeOrAbsolute);//url指向sample.mp4 fil
}
私有异步void altyazikaydet(字符串altyaziurl)
{
尝试
{
HttpWebRequest request=(HttpWebRequest)HttpWebRequest.Create(altyaziurl);
使用(var response=(HttpWebResponse)(wait Task.Factory.fromsync(request.BeginGetResponse,request.EndGetResponse,null)))
{
使用(var responseStream=response.GetResponseStream())
{
使用(var sr=新的StreamReader(responseStream))
{
alinanveri=wait sr.ReadToEndAsync();
}
}
}
IsolatedStorageFile=IsolatedStorageFile.GetUserStoreForApplication();
StreamWriter yazici=新的StreamWriter(新的隔离存储文件流(“altyazi.vtt”,FileMode.Create,file));
字符串x=alinanveri;
x=x。替换(“,0“,”.0”);
x=x。替换(“,1”,“.1”);
x=x。替换(“,2“,”.2”);
x=x。替换(“,3“,”.3”);
x=x。替换(“,4“,”.4”);
x=x。替换(“,5“,”.5”);
x=x。替换(“,6“,”.6”);
x=x。替换(“,7“,”.7”);
x=x。替换(“,8“,”.8”);
x=x。替换(“,9“,”.9”);
x=“WEBVTT文件”+Environment.NewLine+x;
雅兹茨.莱特林(x);
yazici.Close();
IsolatedStorageFile kayitliDepo=IsolatedStorageFile.GetUserStoreForApplication();
StreamReader okuyucu=新的StreamReader(新的隔离存储文件流(“altyazi.vtt”,FileMode.Open,kayitliDepo));
弦线;
而((line=okuyucu.ReadLine())!=null)
{
MessageBox.Show(行);
}
}
抓住
{
}
}

不确定这是否有效,但从中,您可以尝试此方法

string fullpath = "";
using (IsolatedStorageFile kayitliDepo = IsolatedStorageFile.GetUserStoreForApplication())
{     
    IsolatedStorageFileStream stream = kayitliDepo.OpenFile("altyazi.vtt", FileMode.Open,FileAccess.Read);
    fullpath = stream.Name;
}
caption.Source = new Uri(Name,Urikind.Absolute); // url points to sample.vtt file
caption.Description = "Türkçe";            
player.AvailableCaptions.Add(caption);
player.SelectedCaption = player.AvailableCaptions.FirstOrDefault();

我在Windows UWP中也遇到了同样的问题。
player.Source
允许绝对本地URI,但webvtt插件不允许

最后,我发现了如何让它工作:

using System.IO;

var caption = new Caption
{
    Description = "whatever",
    Source = new Uri(Path.Combine("ms-appdata:///Local/", "test.vtt"))
};

Player.AvailableCaptions.Add(caption);
Player.SelectedCaption = Player.AvailableCaptions.FirstOrDefault();