'=====================================================
'设置声音大小
'=====================================================
Public Function SetVolume(Volume As Long) As Boolean
Dim RefInt As Long
SetVolume = False
RefInt = mciSendString("setaudio NOWMUSIC volume to " & Volume, vbNull, 0, 0)
If RefInt = 0 Then SetVolume = True
End Function
'=====================================================
'设置播放速度
'=====================================================
Public Function SetSpeed(Speed As Long) As Boolean
Dim RefInt As Long
SetSpeed = False
RefInt = mciSendString("set NOWMUSIC speed " & Speed, vbNull, 0, 0)
If RefInt = 0 Then SetSpeed = True
End Function
'====================================================
'静音True为静音,FALSE为取消静音
'====================================================
Public Function SetAudioOnOff(AudioOff As Boolean) As Boolean
Dim RefInt As Long
Dim OnOff As String
SetAudioOff = False
If AudioOff Then OnOff = "off" Else OnOff = "on"
RefInt = mciSendString("setaudio NOWMUSIC " & OnOff, vbNull, 0, 0)
If RefInt = 0 Then SetAudioOff = True
End Function
'====================================================
'是否有画面True为有,FALSE为取消
'====================================================
Public Function SetWindowShow(WindowOff As Boolean) As Boolean
Dim RefInt As Long
Dim OnOff As String
SetWindowShow = False
If WindowOff Then OnOff = "show" Else OnOff = "hide"
RefInt = mciSendString("window NOWMUSIC state " & OnOff, vbNull, 0, 0)
If RefInt = 0 Then SetWindowShow = True
End Function
'====================================================
'获得当前媒体的状态是不是在播放
'====================================================
Public Function IsPlaying() As Boolean
Dim sl As String * 255
mciSendString "status NOWMUSIC mode", sl, Len(sl), 0
If Left(sl, 7) = "playing" Or Left(sl, 2) = "播放" Then
IsPlaying = True
Else
IsPlaying = False
End If
End Function
'====================================================
'获得播放窗口的handle
'====================================================
Public Function GetWindowHandle() As Long
Dim RefStr As String * 160
mciSendString "status NOWMUSIC window handle", RefStr, 80, 0
GetWindowHandle = Val(RefStr)
End Function
'====================================================
'获取DeviceID
'====================================================
Public Function GetDeviceID() As Long
GetDeviceID = mciGetDeviceID("NOWMUSIC")
End Function