我使用IsolatedStorage與音頻代理如下通信:的Windows Phone開發 - IsolatedStorage
在每一個我的網頁:
private void playButton_Click(object sender, RoutedEventArgs e)
{
if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
{
BackgroundAudioPlayer.Instance.Pause();
}
else
{
IsolatedStorageSettings.ApplicationSettings["BtnClicked"] = "1"; (or 2 or 3)
IsolatedStorageSettings.ApplicationSettings.Save();
BackgroundAudioPlayer.Instance.Stop();
BackgroundAudioPlayer.Instance.Play();
}
}
在我AudioPlayer.cs:
'的情況下UserAction.Play:
if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "1")
{
_playList = _playList1;
}
else if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "2")
{
_playList = _playList;
}
else if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "3")
{
_playList = _playList2;
}
PlayTrack(player); `
然而問題是「_playlist」變量沒有被啓動除第一次以外。例如,如果我打開頁面1,它會正確選擇_playlist1,但如果按「返回」,然後輸入第2頁,它仍會選擇_Playlist1。如何在每次在我的應用程序中選擇新頁面時強制更新變量?另外,代碼的其餘部分是非常相似的:http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202978%28v=vs.105%29.aspx
播放列表應與按鈕單擊更改(如代碼設辦)或頁面導航?你的播放列表是否在BAP中是靜態的?的 – Romasz
可能重複[我怎樣才能保存在IsolatedStorage中的設置,而BackgroundAudioPlayer的情況下被激活?](http://stackoverflow.com/questions/17760531/how-can-i-save-the-settings-in-the-存儲背景音樂播放器) –