Help needed for MP3 player

Community Forums/General Help/Help needed for MP3 player

asoed(Posted 2009) [#1]
I need a way to get the lenght of an mp3 or need to know when it is finished playing so my player can continue withj the next song. Any ideas? anyone?

I found these 2 examples but I see no way to get the lenght of a song or position:

' mci based windows media controller
' derived from http://www.gamedev.net/reference/articles/article2053.asp

Extern "win32"

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

End Extern

Local file$
Local cmd$
Local result

file="E:\music\Bloc Party\Silent Alarm\01 Like Eating Glass.mp3"

cmd="open ~q"+file+"~q alias mysound"

result=mciSendStringA(cmd)

Print "result="+result

cmd="play mysound from 0"

result=mciSendStringA(cmd)

Print "result="+result

Input "hit enter to end"
End

And another one:
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