返回声音文件的长度.
#include <Sound.au3>
_SoundLength ( $aSnd_id [, $iMode ] )
$aSnd_id | 由 _SoundOpen() 返回的声音 ID 数组或者一个文件名 |
$iMode | [可选参数] 这个标志决定返回的声音长度 1 = hh:mm:ss 这里 h = 小时, m = 分钟 s = 秒 2 = 毫秒 |
成功: | 声音长度 |
失败: | 返回 0 并设置 @error |
@error: | 1 = $iMode 无效 |
3 = 无效声音 ID. 请使用 _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
MsgBox(4096, "Sound Length", "The Sound has a length of:" & @CRLF & "hh:mm:ss - " & _
_SoundLength($aSound, 1) & @CRLF & "Milliseconds - " & _SoundLength($aSound, 2))