以下のように、IsolatedStorage を使用して Audio エージェントと通信しています。
私の各ページで:
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 で:
`case 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と非常によく似ています。