保存到隔离存储后如何自动打开(播放)文件?WP8 [英] How do you Automatically open(play) file after it is saved to isolation storage? WP8

查看:14
本文介绍了保存到隔离存储后如何自动打开(播放)文件?WP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为它应该在 OpenReadCompleted 事件中的某个位置,但我尝试过的任何内容都不起作用.下面的代码包括如果文件已经存在的部分,它将播放,这是有效的.但我希望它在最初下载后也能自动播放.

I think it should go somewhere in the OpenReadCompleted event but nothing I have tried is working. The code below includes the portion where if the file already exists, it will Play, which works. But I would like it to also play automatically after initially downloading.

audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFiledata.SavePath,FileMode.Open, FileAccess.Read, FileShare.Read);    

AudioPlayer.SetSource(audioStream);
AudioPlayer.Play();
}
else
{

            WebClient client = new WebClient();
            client.OpenReadCompleted += (senderClient, args) =>
                {
                    using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))  
                    {
                        args.Result.Seek(0, SeekOrigin.Begin);
                        args.Result.CopyTo(fileStream);
                    }
                };
            client.OpenReadAsync(new Uri(data.FilePath));
}

推荐答案

我可以发誓我早点尝试过,但没有奏效.这是我的解决方案.在 args 后添加 AudioPlayer 代码,如下所示:

I could have swore I tried this earlier and it didn't work. Here was my solution. Added AudioPlayer code after args like so:

     using (IsolatedStorageFileStream fileStream =  IsolatedStorageFile.GetUserStoreForApplication).CreateFile(data.SavePath))                     
{                         
args.Result.Seek(0, SeekOrigin.Begin);
args.Result.CopyTo(fileStream);
AudioPlayer.SetSource(fileStream); 
AudioPlayer.Play();

这篇关于保存到隔离存储后如何自动打开(播放)文件?WP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆