如何在文件保存到隔离存储后自动打开(播放)文件?WP8



我认为它应该在OpenReadCompleted事件的某个地方,但我没有尝试过任何工作。下面的代码包括如果文件已经存在,它将播放的部分,这是有效的。但我希望它也自动播放后,最初下载。

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));
}

我可以发誓我早些时候尝试过这个,它没有工作。这是我的解决方案。在参数后面添加AudioPlayer代码,如下所示:

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

最新更新