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# 如何播放特定歌曲背景AudioPlayer windows phone?_C#_Windows Phone 7_Windows Phone 8_Windows Phone - Fatal编程技术网

C# 如何播放特定歌曲背景AudioPlayer windows phone?

C# 如何播放特定歌曲背景AudioPlayer windows phone?,c#,windows-phone-7,windows-phone-8,windows-phone,C#,Windows Phone 7,Windows Phone 8,Windows Phone,嗨,我正在尝试播放一首特定的歌曲,例如,如果我有一个包含100首歌曲的列表,我想播放20首歌曲 为此,我使用以下代码 private void playSong(int n) { IsolatedStorageSettings.ApplicationSettings["currentSong"] = n; if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing) { Bac

嗨,我正在尝试播放一首特定的歌曲,例如,如果我有一个包含100首歌曲的列表,我想播放20首歌曲

为此,我使用以下代码

private void playSong(int n)
{
    IsolatedStorageSettings.ApplicationSettings["currentSong"] = n;

    if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing)
    {

        BackgroundAudioPlayer.Instance.Close();

        BackgroundAudioPlayer.Instance.Play();

    }
    else
        BackgroundAudioPlayer.Instance.Play();
}
然后在我的AudioPlayer.cs中我得到了这首歌

//get the song
currentSong = (int)IsolatedStorageSettings.ApplicationSettings["currentSong"];
它工作正常,但加载歌曲需要太多时间

请问还有其他方法吗


谢谢。

如果你知道这首歌的位置和文件名,加载它应该不会花太长时间。显示按索引获取歌曲的代码段。