Difference between revisions of "SNDGETPOS"

From QB64 Wiki
Jump to navigation Jump to search
imported>SMcNeill
imported>Odin
m (1 revision imported)
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:


{{PageSyntax}}
{{PageSyntax}}
:{{Parameter|position}} = '''_SNDGETPOS('''{{Parameter|handle&}}''')'''
:{{Parameter|position}} = [[_SNDGETPOS]]({{Parameter|handle&}})




{{PageDescription}}
{{PageDescription}}
*Returns the currently playing position in seconds.
*Returns the current playing position in seconds from an open sound file.
*If a sound isn't playing, it returns 0.
*If a sound isn't playing, it returns 0.
*If a sound is paused, it returns the paused position.
*If a sound is paused, it returns the paused position.
*For a looping sound, the value returns to 0 when the sound restarts.
*For a looping sound, the value returned continues to increment and does not reset to 0 when the sound loops.
* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"SETPOS" capability]] to use this function.
 
 
{{PageExamples}}
''Example:'' To check the current playing position in an MP3 file, use [[_SNDPLAY]] with [[_SNDGETPOS]] printed in a loop:
{{CodeStart}} '' ''
SoundFile& = {{Cl|_SNDOPEN}}("YourSoundFile.mp3") '<<< your MP3 sound file here!
{{Cl|_SNDSETPOS}} SoundFile&, 5.5  'set to play sound 5 1/2 seconds into music
{{Cl|_SNDPLAY}} SoundFile&  'play sound
Do: {{Cl|_LIMIT}} 60   
  LOCATE 5, 2: PRINT "Current play position> "; {{Cl|_SNDGETPOS}}(SoundFile&)
LOOP UNTIL {{Cl|_KEYDOWN}}(27) OR {{Cl|NOT}} {{Cl|_SNDPLAYING}}(SoundFile&) 'ESC or end of sound exit
{{CodeEnd}}
 


{{PageSeeAlso}}
{{PageSeeAlso}}

Latest revision as of 03:16, 1 November 2017

The _SNDGETPOS function returns the current playing position in seconds using a handle from _SNDOPEN.


Syntax

position = _SNDGETPOS(handle&)


Description

  • Returns the current playing position in seconds from an open sound file.
  • If a sound isn't playing, it returns 0.
  • If a sound is paused, it returns the paused position.
  • For a looping sound, the value returned continues to increment and does not reset to 0 when the sound loops.
  • In versions prior to build 20170811/60, the sound identified by handle& must have been opened using the "SETPOS" capability to use this function.


Examples

Example: To check the current playing position in an MP3 file, use _SNDPLAY with _SNDGETPOS printed in a loop:

SoundFile& = _SNDOPEN("YourSoundFile.mp3") '<<< your MP3 sound file here! _SNDSETPOS SoundFile&, 5.5 'set to play sound 5 1/2 seconds into music _SNDPLAY SoundFile& 'play sound Do: _LIMIT 60 LOCATE 5, 2: PRINT "Current play position> "; _SNDGETPOS(SoundFile&) LOOP UNTIL _KEYDOWN(27) OR NOT _SNDPLAYING(SoundFile&) 'ESC or end of sound exit


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page