寻道指定位置的声音
#include <Sound.au3>
_SoundSeek (ByRef $aSnd_id, $iHour, $iMin, $iSec )
$aSnd_id | 由 _SoundOpen() 返回的声音数组 ID |
$iHour | 寻道到小时 |
$iMin | 寻道到分钟 |
$iSec | 寻道到秒钟 |
成功: | 返回 1 | |
失败: | 返回 0,设置@error: | |
@error: | 1 = 失败 | |
3 = 无效的声音标识. 使用 _SoundOpen()返回的数组. |
#include <Sound.au3>
Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
MsgBox(4096, "错误", "文件不存在")
Exit
ElseIf @extended <> 0 Then
Local $iExtended = @extended ;赋值, 因为 @extended 可能会在 DllCall 后被设置成其它返回值
Local $tText = DllStructCreate("char[128]")
DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "ptr", DllStructGetPtr($tText), "int", 128)
MsgBox(4096, "错误", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(4096, "Success", "The file opened successfully")
EndIf
_SoundPlay($aSound, 0)
;播放声音一秒
Sleep(1000)
;搜寻定位到声音的 2 秒处
_SoundSeek($aSound, 0, 0, 2)
ConsoleWrite("After _SoundSeek: " & _SoundPos($aSound, 2) & " _SoundStatus: " & _SoundStatus($aSound) & @CRLF)
_SoundSeek($aSound, 0, 0, 1)
ConsoleWrite("After _SoundSeek1: " & _SoundPos($aSound, 2) & " _SoundStatus: " & _SoundStatus($aSound) & @CRLF)
_SoundPlay($aSound, 0)
While 1
Sleep(100)
If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd
_SoundClose($aSound)