Playing MP3's

BlitzMax Forums/BlitzMax Beginners Area/Playing MP3's

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

heres a quick class

Extern "win32"

Function mciSendStringA(cmd$z,resultbuffer:Byte Ptr=Null,buffersize:Int=0,hwndcallback:Int=0)

End Extern

Type TMusic
	Global musicnumber:Int=0
	Field number:Int,paused:Int
	Field playing:Int
	Function Open:TMusic(sfile:String)
		Local music:TMusic=New TMusic
		music.number=TMusic.musicnumber
		TMusic.musicnumber:+1
		music.Load(sfile)
		Return music
	End Function
	
	Method Load(sfile:String)
		mciSendStringA("open ~q"+sfile+"~q alias "+Name())
	End Method
		
	Method Play(from:Int=0)
		If Not paused 
			mciSendStringA("play "+Name()+" from "+from*1000)
			playing=1
		Else
			mciSendStringA("resume "+Name())
			playing=True
			paused=False
		EndIf
	End Method
	
	Method Pause()
		If paused Return
		mciSendStringA("pause "+Name())
		paused=True
		playing=False
	End Method
	
	Method Stop()
		mciSendStringA("stop "+Name())
		playing=False
		paused=False
	End Method
	
	Method Name:String()
		Return ("TMusic"+String(number))
	End Method
	
End Type