下面提到的按钮单击方法可用于开始播放音频文件.但是,一旦它启动就无法暂停,如果我再次点击该按钮,歌曲将从头开始再次播放.请让我知道使用Enter键停止它的方法. private void btn_repr
private void btn_reproducir_Click(object sender, EventArgs e) { WindowsMediaPlayer myplayer = new WindowsMediaPlayer(); myplayer.URL = @"C:\song.mp3"; myplayer.controls.play(); }请试试这段代码.
public partial class Form1 : Form { // Media player object WindowsMediaPlayer myplayer = new WindowsMediaPlayer(); public Form1() { InitializeComponent(); myplayer.URL = @"C:\song.mp3"; } private void reproducir_Click(object sender, EventArgs e) { myplayer.controls.play(); } private void btnStop_Click(object sender, EventArgs e) { myplayer.controls.stop(); } private void btnPause_Click(object sender, EventArgs e) { myplayer.controls.pause(); } }