GetSoundPosition()

Syntax

Result = GetSoundPosition(#Sound [, Mode [, Channel]])
Description
Get the current sound position.

Parameters

#Sound The sound to use.
Mode (optional) The mode used to get the position. It can be one of the following value:
  #PB_Sound_Frame      : the position is returned in frame (default). 
  #PB_Sound_Millisecond: the position is returned in milliseconds.
Channel (optional) The channel to get the position. It's the value returned by PlaySound() when using the #PB_Sound_MultiChannel flag.

Return value

The current sound position or -1 if an error occurred.

Remarks

Sounds loaded with the #PB_Sound_Streaming flag are not supported.

Example

  If InitSound()           ; Initialize Sound system
    UseOGGSoundDecoder()   ; Use ogg files
    
    ; Loads 2 sounds
    If LoadSound(0, #PB_Compiler_Home + "Examples/3D/Data/Siren.ogg")
      If LoadSound(1, #PB_Compiler_Home + "Examples/3D/Data/Roar.ogg")
        
        ; The siren is playing 
        PlaySound(0)
        
        ; Display the position
        Repeat
          Pos = GetSoundPosition(0, #PB_Sound_Millisecond)
          Delay(100)     ; Wait 100 ms
          Debug Pos      ; Display the position
          If Pos > 1000  ; Stop after 1 second
            Break
          EndIf
        ForEver
        
        ; Then 2 sounds are playing together
        PlaySound(1)
        
        MessageRequester("Info", "Ok to stop.") 
        End
      EndIf
    EndIf
  Else
    Debug "Warning! The sound environment couldn't be initialized. So no sound commands can be used..."
  EndIf

See Also

SetSoundPosition()

Supported OS

All

<- GetSoundFrequency() - Sound Index - InitSound() ->