这是我的代码我试图制作一个停止,暂停和开始按钮,我对编程很新,但是void位给我一个错误,命名空间不能直接包含诸如字段或方法之类的成员。
void MusicPlayer_CurrentStateChanged(object sender, RoutedEventArgs e)
{
switch (musicPlayer.CurrentState)
{
case MediaElementState.Playing:
systemControls.PlaybackStatus = MediaPlaybackStatus.Playing;
break;
case MediaElementState.Paused:
systemControls.PlaybackStatus = MediaPlaybackStatus.Paused;
break;
case MediaElementState.Stopped:
systemControls.PlaybackStatus = MediaPlaybackStatus.Stopped;
break;
case MediaElementState.Closed:
systemControls.PlaybackStatus = MediaPlaybackStatus.Closed;
break;
default:
break;
}
}
答案 0 :(得分:1)
你可能缺少一个类,并且直接在命名空间中编写方法。