用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧VisualBasic

如 何 用 API 播 放 CD

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 19:45:41
'Author: Gordon F. MacLeod
' How to play a CD Audio disc via API

' Declare the following API
Declare Function mciSendString& Lib "MMSYSTEM" (ByVal lpstrCommand$,ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal hCallBack%)

'Add the code below to appropriate routines

Sub cmdPlay_Click ()
  Dim lRet As Long
  Dim nCurrentTrack As Integer

  'Open the device
  lRet = mciSendString("open cdaudio alias cd wait", 0&, 0, 0)

  'Set the time format to Tracks (default is milliseconds)
  lRet = mciSendString("set cd time format tmsf", 0&, 0, 0)

  'Then to play from the beginning
  lRet = mciSendString("play cd", 0&, 0, 0)

  'Or to play from a specific track, say track 4
  nCurrentTrack = 4
  lRet = mciSendString("play cd from" & Str(nCurrentTrack), 0&, 0, 0)

End Sub
 

' Remember to Close the device when ending playback

Sub cmdStop_Click ()
  Dim lRet As Long

  'Stop the playback
 
lRet = mciSendString("stop cd wait", 0&, 0, 0)

  DoEvents  'Let Windows process the event

  'Close the device
 
lRet = mciSendString("close cd", 0&, 0, 0)

End Sub

 


Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:30,218.75000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号