BASS and MaxGUI

BlitzMax Modules Forums/Brucey's Modules/BASS and MaxGUI

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.

Thanks, Brucey! I got it working! Here's the code, just in case anybody wants to see how I did it:

Strict
Import maxgui.win32maxgui
Import bah.bass

If Not TBass.Init(-1,44100,0,Null,Null)
	Print "Unable to start BASS."
	End
EndIf

Global file:TStream=ReadStream("music.mp3")
Global song:TBassStream=New TBassStream.CreateTStream(file,0,0)
If Not song End

Global window:TGadget=CreateWindow(AppTitle,0,0,640,480,Null)
Global slider:TGadget=CreateSlider(10,10,ClientWidth(window)-20,24,window,SLIDER_HORIZONTAL|SLIDER_TRACKBAR)
SetGadgetSensitivity(slider,SENSITIZE_MOUSE)

Global l:Long=song.GetLength(BASS_POS_BYTE)
Global songlength:Int=song.Bytes2Seconds(l)
Print Float(songlength/60)+" Minutes"

SetSliderRange(slider,1,songlength)

song.play(True)

Global updatetimer=MilliSecs()

Repeat
	PollEvent()
	Select EventID()
		Case event_windowclose
			Select EventSource()
				Case window
					TBass.Free()
					End
			EndSelect
		
		Case event_mouseup
			Select EventSource()
				Case slider
					Local v:Int=SliderValue(slider)
					Local pos:Long=song.Seconds2Bytes(v)
					song.SetPosition(pos,BASS_POS_BYTE)
			EndSelect
	EndSelect
	
	If MilliSecs()>updatetimer+1000
		Local pos:Long=song.GetPosition(BASS_POS_BYTE)
		Local songpos:Int=song.Bytes2Seconds(pos)
		
		SetSliderValue(slider,songpos)
		updatetimer=MilliSecs()
	EndIf
Forever