Skip to main content

SoundPlayer

SoundPlayer (Function)

Format

soundplayer ( filename )
soundplayer ( url )
soundplayer ( resource )
soundplayer ( array[] )

returns integer_expression

Description

Builds a sound instance without starting it and returns its player#. This is the id you need whenever you want to address a specific sound later — SoundPlay, SoundLength, SoundSeek, SoundPause and friends all take this integer id.

Unlike SoundPlay with a string argument (which creates a fresh instance on every call), a player is a single reusable instance: starting, pausing, and stopping it always addresses the same sound.

Example

music = soundplayer("song.mp3")
soundplay music # start it
pause 2.0
soundpause music # pause it
pause 1.0
soundplay music # resume from where it paused
soundwait music # wait for the end

See Also

Sound, SoundLength, SoundLoad, SoundPause, SoundPlay, SoundPosition, SoundSeek, SoundState, SoundStop, SoundVolume, SoundWait

Availability

BASIC-256 2.0 and later. Documented from the BASIC-256 v2.1 continuation project.