Function Reference


_SoundSeek

Seeks the sound to the specified position

#include <Sound.au3>
_SoundSeek ( ByRef $aSndID, $iHour, $iMin, $iSec )

Parameters

$aSndID Sound ID array as returned by _SoundOpen()
$iHour Hour to seek to
$iMin Minute to seek to
$iSec Second to seek to

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 = Failure
3 = Invalid Sound ID. Use return array from _SoundOpen().

Remarks

After using _SoundSeek() on a sound, _SoundPlay() must be used to resume playing.
The use of the ID array returned from _SoundOpen() is mandatory with this function to ensure that the file plays from the correct position regardless of encoding type.
The ID array should be updated by the function as the VBR timing correction factor may have been altered.

Related

_SoundPlay

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)

; Play one second of sound.
Sleep(1000)

; Seek to 2 seconds into the sound.
_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)