| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:[求助]请各位,解释一下,这段播放cd的代码
只看楼主 加入收藏
sky00606
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-19
收藏
 问题点数:0 回复次数:0 
[求助]请各位,解释一下,这段播放cd的代码

我在网上下载了一个vb小程序,看不太懂,因为初学vb,能不能给我解释一下,在线等
很着急,谢谢了

Option Explicit
Dim trackLength(20) As String
Dim min As Integer
Dim track1 As Integer
Dim sec As Integer

Private Sub cmdClose_Click()
mciSendString "stop MyMedia", vbNullString, 0, 0
mciSendString "close MyMedia", vbNullString, 0, 0
End Sub

Private Sub cmdDoorClose_Click()
mciSendString "set MyMedia door closed", vbNullString, 0, 0
End Sub

Private Sub cmdEject_Click()
mciSendString "set MyMedia door open", vbNullString, 0, 0
End Sub

Private Sub cmdNext_Click()
Dim S As String, Tracks As Integer, CurTrack As Integer
S = String(256, Chr(0))
mciSendString "status MyMedia number of tracks", S, Len(S), 0
Tracks = Val(S)

mciSendString "status MyMedia current track", S, Len(S), 0
CurTrack = Val(S)

If CurTrack < Tracks Then
mciSendString "status MyMedia position track " & CurTrack + 1, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0
End If
End Sub

Private Sub cmdOpen_Click()
Dim ret As Long, S As String
Dim i As Integer

mciSendString "close MyMedia", vbNullString, 0, 0
ret = mciSendString("open cdaudio alias MyMedia", vbNullString, 0, 0)

If ret = 0 Then
Dim Length As String, Tracks As Integer

S = String(256, Chr(0))
mciSendString "status MyMedia length", S, Len(S), 0
Length = Left(S, 8)

mciSendString "status MyMedia number of tracks", S, Len(S), 0
Tracks = Val(S)
For i = 1 To Tracks
List1.AddItem "第 " & i & " 首CD"
Next i

txtLength.Text = "[" & Tracks & "] " & Length
Else
S = String(256, Chr(0))
mciGetErrorString ret, S, Len(S)
MsgBox Left(S, InStr(S, Chr(0)) - 1)
End If
End Sub

Private Sub cmdPause_Click()
mciSendString "pause MyMedia", vbNullString, 0, 0
End Sub

Private Sub cmdPlay_Click()
mciSendString "play MyMedia", vbNullString, 0, 0
End Sub

Private Sub cmdPrev_Click()
Dim S As String, CurTrack As Integer
S = String(256, Chr(0))
mciSendString "status MyMedia current track", S, Len(S), 0
CurTrack = Val(S)
If CurTrack > 1 Then
mciSendString "status MyMedia position track " & CurTrack - 1, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0
End If
End Sub

Private Sub cmdReset_Click()
mciSendString "pause MyMedia", vbNullString, 0, 0
mciSendString "seek MyMedia to start", vbNullString, 0, 0
End Sub

Private Sub cmdVolume_Click()
Shell "Sndvol32.exe", vbNormalFocus
End Sub

Private Sub Form_Load()
Dim S As String
Dim i As Integer
S = String(256, Chr(0))
mciSendString "status cdaudio number of tracks", S, Len(S), 0
If Val(S) <> 0 Then cmdOpen_Click
mciSendString "play MyMedia", vbNullString, 0, 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
cmdClose_Click
End Sub

Private Sub List1_DblClick()
Dim S As String, k As Integer
S = String(256, Chr(0))
k = List1.ListIndex + 1
mciSendString "status MyMedia position track " & k, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0

End Sub

Private Sub Timer1_Timer()
Dim S As String, ret As Long, pos As String, track As Integer
S = String(256, 0)
mciSendString "status MyMedia position", S, Len(S), 0
pos = Left(S, 8)
mciSendString "status MyMedia current track", S, Len(S), 0
track = Val(S)
txtCurrent = "[" & track & "] " & pos
End Sub

Private Sub Timer2_Timer()
If List1.ListCount = 0 Then
cmdOpen_Click
End If
End Sub

搜索更多相关主题的帖子: 解释 播放 代码 
2006-05-19 16:11
快速回复:[求助]请各位,解释一下,这段播放cd的代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040945 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved