SoundLength()

Syntax

SoundLength(#Sound [, Mode])
Description
Get the length of the sound.

Parameters

#Sound The sound to use.
Mode (optional) The mode used to get the length. It can be one of the following value:
  #PB_Sound_Frame      : the length is returned in frame (default). 
  #PB_Sound_Millisecond: the length is returned in milliseconds.

Return value

The length of the sound, 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 a sound from a file
    If LoadSound(0, #PB_Compiler_Home +"Examples/3D/Data/Siren.ogg")
      ; The sound is playing
      PlaySound(0, #PB_Sound_Loop, 20)
      
      MessageRequester("Info", "The length of the sound is "+ Str(SoundLength(0)) + " frames.")
      
      MessageRequester("Info", "The length of the sound is "+ Str(SoundLength(0, #PB_Sound_Millisecond)) + " ms.")
      
      FreeSound(0) ; The sound is freed
      End
    EndIf
  Else
    Debug "Warning! The sound environment couldn't be initialized. So no sound commands can be used..."
  EndIf

Supported OS

All

<- SetSoundPosition() - Sound Index - SoundPan() ->