オーディオトラックを表示するページを作成してLongListboxSelectorいます。各アイテムにはButton「プレイ」がありTextBlock、アーティストとタイトルの情報が含まれています。私はを使用してBackgroundAudioPlayerいます。私の望みは次を作ることです:トラックが再生されているとき-の画像Buttonは「一時停止」、トラックが終わっているとき-そのButton画像を「再生」し、次のトラックのButton画像を「一時停止」にします(次のトラックは自動的に再生されます)。私はこれが好きだと思うことを試みました
public AudioListPage()
{
InitializeComponent();
BackgroundAudioPlayer.Instance.PlayStateChanged += Instance_PlayStateChanged;
}
void Instance_PlayStateChanged(object sender, EventArgs e)
{
if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Stopped)
{
IEnumerable buttons = AudioLLS.Descendants<Coding4Fun.Phone.Controls.RoundButton>();
var test = new BitmapImage(new Uri(@"/Images/appbar.transport.pause.rest.png", UriKind.Relative));
foreach (Coding4Fun.Phone.Controls.RoundButton item in buttons)
{
if (item.ImageSource == test)
{
MessageBox.Show("in new image");
item.ImageSource = new BitmapImage(new Uri(@"/Images/appbar.transport.play.rest.png", UriKind.Relative));
buttons.GetEnumerator().MoveNext();
item.ImageSource = new BitmapImage(new Uri(@"/Images/appbar.transport.pause.rest.png", UriKind.Relative));
}
}
}
}
PlayState.Stoppedトラックが終了すると発火し、次が開始されます。LinqToVisualTreeヘルパーを使用してLLSのすべてのボタンを取得しIEnumerable buttons = AudioLLS.Descendants<Coding4Fun.Phone.Controls.RoundButton>()、それらの画像をと比較しようとしましたtest。しかし、私が見ることができるように-私はそれを間違っています。なぜなら、ブロックでif(item.ImageSource == test)は私のアプリが決して来ないからです。教えてください、私が間違っていることは何ですか?そして、問題を解決する私の方法が悪い場合は、簡単な方法でそれを行う方法を教えてください。