MP3 Decoder Question

BlitzMax Forums/BlitzMax Programming/MP3 Decoder Question

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.

Framework MaxGUI.MaxGUI
Import MaxGUI.Win32MaxGUI
Import MaxMod.AudioStream
Import MaxMod.ModPlayer
Import MaxMod.Ogg
Import MaxMod.MP3

SetAudioDriver("directsound")
New TApp

Type TApp

	Field Stream:TChannel
	Field Win   :TGadget = CreateWindow("MaxMod+GUI Example",0,0,180,20,Null,WINDOW_TITLEBAR|WINDOW_CENTER|WINDOW_CLIENTCOORDS)
	Field Eject :TGadget = CreateButton("Eject",0,0,60,20,Win)
	Field Play  :TGadget = CreateButton("Play",60,0,60,20,Win)
	Field Pause :TGadget = CreateButton("Pause",120,0,60,20,Win)

	Method New()
		AddHook EmitEventHook,eventhook,Self
		Repeat
			WaitEvent()
		Forever
	EndMethod

	Function eventhook:Object(id:Int,data:Object,context:Object)
		If TApp(context) Then TApp(context).OnEvent(TEvent(data))
		Return data
	End Function

	Method OnEvent(event:TEvent)
		Select event.id
		
			Case EVENT_WINDOWCLOSE
				If Event.Source=Win Then MinimizeWindow(Win) ; Delay 100 ; End
				
			Case EVENT_GADGETACTION
				Select Event.Source
					Case Eject
						Local File$ = RequestFile("",MusicExtensions())
						If FileType(File)<>FILETYPE_FILE Then Return
						Local TempStream:TChannel = CreateAudioStream(File,True,True)
						If Not TempStream Notify "Unable to Stream Music" ; Return
						If Stream Then StopChannel(Stream)
						Stream = TempStream
						ResumeChannel Stream
					Case Play
						If Stream ResumeChannel Stream
					Case Pause
						If Stream PauseChannel Stream
				EndSelect
				
		EndSelect
	End Method

EndType

This version of maxmod is really only designed for use in games, so if you want position sliders and such you'd be better off using FMOD, or wait forever for the next version of maxmod ;) (which is much more flexible)

Just out of interest, what problems where you having getting it to work?

NOTE: MP3 support is only available on windows in the current release of maxmod.