mmcontrol控件如何播放mp3如题 谢谢了
1个回答
展开全部
楼主您好 在VB中播放MP3有很多种方法,这里说个最简单的方法:利用VB自带的MMControl控件。 首先添加该ActiveX控件 代码示例: Private Sub Command1_Click() PlayMp3 101, "一无所有.mp3"大让卖斗 End Sub Sub PlayMp3(RESid As Integer, Mp3Name As String) If Dir(Environ("temp") & "\" & Mp3Name) = vbNullString Then ResShiFang RESid, Environ("temp") & "\" & Mp3Name End If MMControl1.Command = "close" MMControl1.Notify = False MMControl1.Wait = True MMControl1.FileName = Environ("temp") & "\" & Mp3Name MMControl1.Command = "open" MMControl1.Notify = True MMControl1.Wait = False MMControl1.Command = "play" End Sub Private Sub ResShiFang(RESid As Integer, vDataFileName As String)'将要播放的文件以滚配局资源形式添加然后释放 Dim DataFile() As Byte DataFile = LoadResData(RESid, "MP3") '从资源文件读入文件内容 Open vDataFileName For Binary As #1 '建立数据文件,以二进制方式打开 Put #1, , DataFile Close #1 '写完后关闭文件 End Sub Private Sub Form_Unload(Cancel As Integer) MMControl1.Command = "close" End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询