我正在尝试在 Windows Phone 7 中使用 MediaElement 播放 mp3。这是代码。请帮帮我,我什至没有收到错误...但是这首歌也无法播放...
private void button1_Click_1(object sender, RoutedEventArgs e)
{
mediaElement.Source = new Uri("Song.mp3", UriKind.Relative);
if (mediaElement.CurrentState == MediaElementState.Playing)
{
button1.Content = "Pause";
mediaElement.Pause();
}
else
{
button1.Content = "Play";
mediaElement.Play();
}
}
XAML 页面
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement Height="201" HorizontalAlignment="Left" Margin="9,6,0,0" Name="mediaElement" VerticalAlignment="Top" Width="441" />
<Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="12,213,0,0" Name="button1" VerticalAlignment="Top" Width="438" />
</Grid>