SNDLOOP: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:_SNDLOOP}} The _SNDLOOP statement is like _SNDPLAY but the sound is looped. Uses a handle from the _SNDOPEN function. {{PageSyntax}} : _SNDLOOP {{Parameter|handle&}} {{PageDescription}} *Plays the sound identified by {{Parameter|handle&}} in a loop. {{PageExamples}} ''Example:'' Loading a sound or music file and playing it in a loop until a key is pressed. {{CodeStart}} '' '' bg = {{Cl|_SNDOPEN}}("back.ogg") '<<<<<<<<<< change to your...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 13: Line 13:
{{PageExamples}}
{{PageExamples}}
''Example:'' Loading a sound or music file and playing it in a loop until a key is pressed.
''Example:'' Loading a sound or music file and playing it in a loop until a key is pressed.
{{CodeStart}} '' ''
{{CodeStart}}
bg = {{Cl|_SNDOPEN}}("back.ogg") '<<<<<<<<<< change to your sound file name
bg = {{Cl|_SNDOPEN}}("back.ogg") '<<<<<<<<<< change to your sound file name
{{Cl|_SNDLOOP}} bg
{{Cl|_SNDLOOP}} bg
Line 21: Line 21:
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'key press program exit
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'key press program exit
{{Cl|_SNDSTOP}} bg
{{Cl|_SNDSTOP}} bg
{{Cl|_SNDCLOSE}} bg '' ''
{{Cl|_SNDCLOSE}} bg
{{CodeEnd}}
{{CodeEnd}}



Latest revision as of 02:41, 23 January 2023

The _SNDLOOP statement is like _SNDPLAY but the sound is looped. Uses a handle from the _SNDOPEN function.


Syntax

_SNDLOOP handle&


Description

  • Plays the sound identified by handle& in a loop.


Examples

Example: Loading a sound or music file and playing it in a loop until a key is pressed.

bg = _SNDOPEN("back.ogg") '<<<<<<<<<< change to your sound file name
_SNDLOOP bg

DO
    _LIMIT 10   'keep CPU resources used low
LOOP UNTIL INKEY$ <> "" 'key press program exit
_SNDSTOP bg
_SNDCLOSE bg


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link