计算机二级

3773考试网计算机等级考试计算机二级正文

用MCI命令做一个播放器

来源:fjzsksw.com 2010-4-7 9:36:14

 

  Public Function PlayMusic() As Boolean
  Dim RefInt As Long
  PlayMusic = False
  RefInt = mciSendString("play NOWMUSIC", vbNull, 0, 0)
  If RefInt = 0 Then PlayMusic = True
  End Function
  '======================================================
  '获取媒体的长度
  '======================================================
  Public Function GetMusicLength() As Long
  Dim RefStr As String * 80
  mciSendString "status NOWMUSIC length", RefStr, 80, 0
  GetMusicLength = Val(RefStr)
  End Function
  '======================================================
  '获取当前播放进度
  '======================================================
  Public Function GetMusicPos() As Long
  Dim RefStr As String * 80
  mciSendString "status NOWMUSIC position", RefStr, 80, 0
  GetMusicPos = Val(RefStr)
  End Function
  '======================================================
  '获取媒体的当前进度
  '======================================================
  Public Function SetMusicPos(Position As Long) As Boolean
  Dim RefInt As Long
  SetMusicPos = False
  RefInt = mciSendString("seek NOWMUSIC to " & Position, vbNull, 0, 0)
  If RefInt = 0 Then SetMusicPos = True
  End Function
  '======================================================
  '暂停播放
  '======================================================
  Public Function PauseMusic() As Boolean
  Dim RefInt As Long
  PauseMusic = False
  RefInt = mciSendString("pause NOWMUSIC", vbNull, 0, 0)
  If RefInt = 0 Then PauseMusic = True
  End Function
  '======================================================
  '关闭媒体
  '======================================================
  Public Function CloseMusic() As Boolean
  Dim RefInt As Long
  CloseMusic = False
  RefInt = mciSendString("close NOWMUSIC", vbNull, 0, 0)
  If RefInt = 0 Then CloseMusic = True
  End Function
  '======================================================
  '设置声道
  '======================================================
  Public Function SetAudioSource(sAudioSource As AudioSource) As Boolean
  Dim RefInt As Long
  Dim strSource As String
  Select Case sAudioSource
  Case 1: strSource = "left"
  Case 2: strSource = "right"
  Case 0: strSource = "stereo"
  End Select
  SetAudioSource = False
  RefInt = mciSendString("setaudio NOWMUSIC source to " & strSource, vbNull, 0, 0)
  If RefInt = 0 Then SetAudioSource = True
  End Function

 

上一页  [1] [2] [3] 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1