Skip to content

PlayMusic

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

Blitz3DBlitzPlusBlitzBasic

PlayMusic

PlayMusic:Int32 midifile:String
Parameter Mode Type Default Description
midifile In String required

Returns: The channel the music plays on, or 0 if the file could not be played.

Description

Loads a music file and plays it right away. The returned channel can be paused, resumed, stopped and changed with the Channel commands. Unlike a sound from LoadSound the file is read again each time the command is used, so a short pause is possible for large files. Music plays once and does not loop.

Differences

  • MIDI is not supported, and neither are the tracker formats (MOD, S3M, XM, IT) and WMA. WAV, MP3, OGG and FLAC work.

Examples

; Any music file works, change the path to one of your own.
Local ch = PlayMusic("music.ogg")
If ch = 0 Then Print "Could not play music.ogg" : WaitKey : End
While ChannelPlaying(ch) And Not KeyHit(1)
	Delay 50
Wend
StopChannel ch

Related Commands

PauseChannel, PlayCDTrack, PlaySound, ResumeChannel

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally