vb.net中用media player 播放mp3的问题
我想播放mp3,听说用mediaplayer控件省事。比如,soundplayer是一个mediaplayer控件我要点击按钮后连续播放两个mp3:PrivateSubB...
我想播放mp3,听说用media player控件省事。比如,
soundplayer 是一个media player控件
我要点击按钮后连续播放两个mp3:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.URL = "mp3_1.mp3"
soundplayer.Ctlcontrols.stop()
soundplayer.settings.playCount = 1
soundplayer.Ctlcontrols.play()
soundplayer.URL = "mp3_2.mp3"
soundplayer.Ctlcontrols.stop()
soundplayer.settings.playCount = 1
soundplayer.Ctlcontrols.play()
End Sub
结果只能听到第二个文件,为什么呢,怎么改进?
谢谢 展开
soundplayer 是一个media player控件
我要点击按钮后连续播放两个mp3:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.URL = "mp3_1.mp3"
soundplayer.Ctlcontrols.stop()
soundplayer.settings.playCount = 1
soundplayer.Ctlcontrols.play()
soundplayer.URL = "mp3_2.mp3"
soundplayer.Ctlcontrols.stop()
soundplayer.settings.playCount = 1
soundplayer.Ctlcontrols.play()
End Sub
结果只能听到第二个文件,为什么呢,怎么改进?
谢谢 展开
2个回答
展开全部
你的程序出错的原因是soundplayer.URL定义的播放文件的地址,他是string类型的,当然只能保存一个文件的地址,你用MediaPlayer的时候打开一个文件之后再打开一个新的文件,播放的当然是第二个文件。
多文件的播放应该将文件地址存放在播放列表中。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_1.mp3")
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_2.mp3")
soundplayer.Ctlcontrols.stop()
soundplayer.Ctlcontrols.play()
End Sub
这样改就能按你的想法实现了。
多文件的播放应该将文件地址存放在播放列表中。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_1.mp3")
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_2.mp3")
soundplayer.Ctlcontrols.stop()
soundplayer.Ctlcontrols.play()
End Sub
这样改就能按你的想法实现了。
展开全部
你的程序出错的原因是soundplayer.URL定义的播放文件的地址,他是string类型的,当然只能保存一个文件的地址,你用MediaPlayer的时候打开一个文件之后再打开一个新的文件,播放的当然是第二个文件。
多文件的播放应该将文件地址存放在播放列表中。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_1.mp3")
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_2.mp3")
soundplayer.Ctlcontrols.stop()
soundplayer.Ctlcontrols.play()
End Sub
多文件的播放应该将文件地址存放在播放列表中。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_1.mp3")
soundplayer.currentPlaylist.appendItem(soundplayer.newMedia("mp3_2.mp3")
soundplayer.Ctlcontrols.stop()
soundplayer.Ctlcontrols.play()
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询