vb,不用播放器类控件,播放midi音乐1
发布网友
发布时间:2024-03-21 13:37
我来回答
共1个回答
热心网友
时间:2024-04-02 06:57
用API可以实现播放媒体文件:
'//API声明
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
'//mciSendString 功能非常强大,使用方法却很简单。下面只列举最基本的几个操作方法:
'//装载媒体文件:
mciExecute "open " & yourfile & " alias MEDIA " '//yourfile最好用短路径
'//播放
mciSendString "play MEDIA", vbNullString, 0, 0
'//循环播放
mciSendString "play media repeat", 0&, 0, 0
'//停止:
mciSendString "stop MEDIA", vbNullString, 0, 0
'//关闭:
mciSendString "close MEDIA", vbNullString, 0, 0