|
Option Explicit
'Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1
Declare Function GetTickCount Lib "kernel32" () As Long
Declare Function timeGetTime Lib "winmm.dll" () As Long
Sub Play()
Dim sTime As Date
Dim eTime As Date
Dim vsTime As Integer
Dim vmTime As Integer
Dim vsTime0 As String
Dim lngTime As Long
Dim ssmTime As String
' Dim Sleep1 As Integer
Dim Wait1 As Integer
Dim Wait2 As Integer
Dim nowFrame As Long
Dim Frame As Long
Dim Height As Integer
Dim Count1 As Integer
nowFrame = 0
Count1 = 0
ssmTime = "1:30"
Wait1 = 78
Wait2 = 79
' Sleep1 = 15
Frame = 1127
Height = 68
ActiveWindow.Caption = "Sound seting"
ActiveWindow.ScrollRow = 1
Call PlaySound(ThisWorkbook.Path & "\audio.wav", 0, SND_ASYNC)
' Sleep (Sleep1)
' DoEvents
lngTime = GetTickCount()
sTime = Time
Do Until nowFrame > Frame
If Count1 < 9 Then
If GetTickCount() - lngTime >= Wait1 Then
nowFrame = nowFrame + 1
lngTime = GetTickCount()
ActiveWindow.ScrollRow = nowFrame * Height + 1
Count1 = Count1 + 1
End If
ElseIf Count1 = 9 Then
If GetTickCount() - lngTime >= Wait2 Then
nowFrame = nowFrame + 1
lngTime = GetTickCount()
ActiveWindow.ScrollRow = nowFrame * Height + 1
Count1 = 0
End If
End If
eTime = Time
vsTime = (eTime - sTime) * 24 * 60 * 60
vmTime = vsTime \ 60
vsTime = vsTime Mod 60
vsTime0 = Format(vsTime, "00")
ActiveWindow.Caption = "Playing > Frame: " & nowFrame & "/" & Frame & _
" | Line: " & nowFrame * Height + 1 & "/" & Frame * Height & _
" | Time: " & vmTime & ":" & vsTime0 & "/" & ssmTime
DoEvents
Loop
ActiveWindow.ScrollRow = 1
ActiveWindow.Caption = "Stop"
End Sub
|
|