Function Reference


_SoundPos

Returns the current position of the sound

#include <Sound.au3>
_SoundPos ( $aSndID [, $iMode = 1] )

Parameters

$aSndID Sound ID array as returned by _SoundOpen() or a file name
$iMode [optional] This flag determines which format the position of the sound is returned in
    1 = (by default) hh:mm:ss where h = hours, m = minutes and s = seconds (default)
    2 = milliseconds

Return Value

Success: the sound position.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 = $iMode is invalid
3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

It is recommended to open a sound file with _SoundOpen() and pass the ID array rather than use the file name in this function. A VBR encoded file is very unlikely to return the correct position if the file name is passed directly to this function.

Related

_SoundLength, _SoundOpen

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
        MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
        Exit
ElseIf @extended <> 0 Then
        Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
        Local $tText = DllStructCreate("char[128]")
        DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
        MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
        MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound, 0)
SplashTextOn("Current Position", _SoundPos($aSound, 1), 300, 90, Default, Default, 18, Default, 55)

While 1
        Sleep(100)
        ControlSetText("Current Position", "", "Static1", _SoundPos($aSound, 1))
        If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)