函数参考


_SoundPlay

播放一个声音文件.

#include <Sound.au3>
_SoundPlay($aSnd_id [, $iWait])

参数

$aSnd_id 声音 ID 数组为一个 _SoundOpen 返回的结果或者一个文件名.
$iWait [可选参数] 这个标志定义脚本是否等待声音播放完成后再继续运行脚本:
1 = 等待声音播放完成再继续运行脚本.
0 = 当声音开始播放,脚本继续运行.(默认)

返回值

成功: 1
失败: 0 并设置 @Error
@error: 1 = 播放失败
2 = $iWait 参数无效
3 = 无效声音ID. 请从 _SoundOpen 返回一个数组或者使用一个有效的文件名.

注意/说明

In Vista and above, "\Windows\Media\..." files containing spaces must be opened with _SoundOpen before using this command with the returned Sound ID array.

相关

_SoundPause, _SoundStop, _SoundSeek, _SoundOpen, _SoundResume

示例/演示


#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, 1)

_SoundClose($aSound)