Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 下载的mp3流未从windows phone 7中的隔离存储播放_C#_Windows Phone 7_Windows Phone 8_Httpwebrequest_Webclient - Fatal编程技术网

C# 下载的mp3流未从windows phone 7中的隔离存储播放

C# 下载的mp3流未从windows phone 7中的隔离存储播放,c#,windows-phone-7,windows-phone-8,httpwebrequest,webclient,C#,Windows Phone 7,Windows Phone 8,Httpwebrequest,Webclient,我在应用程序中使用HttpWebRequest和WebClient下载了一首.mp3歌曲。 我正在使用.mp3扩展名将响应流保存在独立存储中。 当我尝试使用BackgroundAudioPlayer播放时,它不会播放 这是我的密码。请说明它有什么问题 using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists(lstBoxSon

我在应用程序中使用HttpWebRequest和WebClient下载了一首.mp3歌曲。 我正在使用.mp3扩展名将响应流保存在独立存储中。 当我尝试使用
BackgroundAudioPlayer播放时,它不会播放

这是我的密码。请说明它有什么问题

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
       if (store.FileExists(lstBoxSongList.SelectedItem as string))
       {
             using (IsolatedStorageFileStream isfStream = store.OpenFile(lstBoxSongList.SelectedItem.ToString(), FileMode.Open, FileAccess.Read))
             {
                    AudioTrack track = new AudioTrack(new Uri(lstBoxSongList.SelectedItem as string, UriKind.RelativeOrAbsolute), lstBoxSongList.SelectedItem.ToString(), "", "", null);
                    BackgroundAudioPlayer.Instance.Track = track;
                    BackgroundAudioPlayer.Instance.Volume = 1;
                    BackgroundAudioPlayer.Instance.Play();
             }
       }
}
下面给出了我将下载的流保存到
IsolatedStorage
中的方法

webClient.OpenReadCompleted += (s1, e1) =>
            {
                if (e1.Error == null)
                {                     
                        bool isSpaceAvailable = IsSpaceIsAvailable(e1.Result.Length);

                        if (isSpaceAvailable)
                        {
                            using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                            {

                                // Save mp3 to Isolated Storage
                                if (store.FileExists(filename))
                                {
                                    store.DeleteFile(filename);
                                }
                                using (var isfs = new IsolatedStorageFileStream(filename, FileMode.CreateNew, IsolatedStorageFile.GetUserStoreForApplication()))
                                {
                                    long fileLen = e1.Result.Length;
                                    byte[] b = new byte[fileLen];
                                    e1.Result.Read(b, 0, b.Length);
                                    isfs.Write(b, 0, b.Length);
                                    isfs.Flush();
                                }
                            }
                       }
                }
           }   
请说明此代码的错误

下面是包含我的文件名的ListBox的Xaml代码

<ListBox Name="lstBoxSongList" SelectionChanged="lstBoxSongList_SelectionChanged" >
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>


能否添加列表框的XAML代码?我认为您检索的项目名称不正确way@fillobotto我在问题中添加了listbox的xaml代码。