Skip to content

PlaySound

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions

Blitz3DBlitzPlusBlitzBasic

PlaySound

PlaySound:Int32 sound:Int32
Parameter Mode Type Default Description
sound In Int32 required A handle from LoadSound.

Returns: The channel handle, or 0 if the sound could not be played (for example without a sound device).

Description

Starts a sound and returns the channel it plays on. Every call starts a new channel, so the same sound can play several times over itself. The channel starts with the volume and pan that were set on the sound with SoundVolume and SoundPan, and a sound that is marked by LoopSound repeats until the channel is stopped.

Differences

  • A debug build (-d) stops the program when the sound is 0 (a sound that failed to load) or does not exist, other builds ignore the command, see Debug handle checks.

Examples

; MakeBeep writes beep.wav, see the LoadSound example for the code.
Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Local snd = LoadSound("beep.wav")
While Not KeyHit(1)
	If KeyHit(57) Then PlaySound snd
	Cls
	Text 10, 10, "Space plays a beep, Escape ends"
	Flip
Wend

Related Commands

FreeSound, Load3DSound, LoadSound, LoopSound, PlayCDTrack, PlayMusic, SoundPan, SoundPitch

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally