GLBasic forum

Main forum => GLBasic - en => Topic started by: fjsantosb on 2009-Dec-15

Title: iPhone - Play while hear his own music
Post by: fjsantosb on 2009-Dec-15
Hi there,

Many of my customers, are asking if in my next update of 'Noid' they could use his own music while playing.
Actually, i think that is not possible on glbasic. I wonder if anyone has get to managed to do this.

King Regards, fjsantos.
Title: Re: iPhone - Play while hear his own music
Post by: codegit on 2009-Dec-16
My customers are asking the same thing. I do not think its possible from GLBASIC alone (please correct me if I am wrong). You will most probably have to try hook into the apple api's from Xcode?  ;/

Title: Re: iPhone - Play while hear his own music
Post by: Kitty Hello on 2009-Dec-16
There is an API for the iPod library. We have to wait for Trucidare I guess.
Title: Re: iPhone - Play while hear his own music
Post by: Ozden79 on 2010-Feb-06
Any news about this, I'm looking forward to it as well...
Title: Re: iPhone - Play while hear his own music
Post by: trucidare on 2010-Feb-06
On Todo right after AGON.
Title: Re: iPhone - Play while hear his own music
Post by: fjsantosb on 2010-Feb-06
Wow, really great!!!

I think that will be a great improvement for GLBasic!

Thanks for share your great work trucidare!

I am a volunteer for beta testing :P.

King Regards, fjsantos.
Title: Re: iPhone - Play while hear his own music
Post by: Mindfield on 2010-Feb-07
I'd definitely like to see this happen as well.  It's a popular option among many players who'd rather have their own music than the in-game music provided.  A way to detect whether the user is already playing music on the iPod at game launch would be good so you can give the player the option of continuing to listen to their music or turn it off to listen to in-game music.
Title: Re: iPhone - Play while hear his own music
Post by: Ozden79 on 2010-Apr-07
Hate to bring this up but this is also something that our customers are asking us a lot... :)
Title: Re: iPhone - Play while hear his own music
Post by: trucidare on 2010-Apr-07
Look at userlibs iPhone Musik
Title: Re: iPhone - Play while hear his own music
Post by: Ozden79 on 2010-Apr-07
Damn, how did I miss that, thank you very much once more, much appreciated... =D
Title: Re: iPhone - Play while hear his own music
Post by: michael on 2011-Jul-22
is there any sample code for this function with glbasic?
Title: Re: iPhone - Play while hear his own music
Post by: Crivens on 2011-Jul-22
Put this in it's own .gbas file attached to your project (mine is GLBMusic.gbas):-
Code: (glbasic) [Select]
// PRoject GLBMusic Wrapper
//
// Wrapper GBAS

//1. -> Download the lib AND gbas from: http://davis.org.au/trucidare/GLBMusic.zip
//2. -> Add GLBMusic.gbas TO your Project
//3. -> Use functions TO add Music support AND compile
//4. -> copy TO mac
//5. -> open xcode project
//6. -> drag AND drop libGLBMusic.a TO frameworks on the left side (dont forget TO add MediaPlayer.framework, thats missing IN the glbasic xcode project, simple right click on frameworks add-> existing frameworks -> choose mediaplayer AND click ok)
//NOTE: It seems Mediaplayer.framework is already there now. No worries...
//7. -> edit info.plist
//8. -> compile AND have fun.


?IFDEF IPHONE
IMPORT "C" void GLB_MP_StartMusicPlayer()
IMPORT "C" void GLB_MP_PlayMusic()
IMPORT "C" void GLB_MP_StopMusic()
IMPORT "C" void GLB_MP_NextTitle()
IMPORT "C" void GLB_MP_PreviousTitle()
IMPORT "C" int GLB_MP_isPlaying()
?ELSE
FUNCTION GLB_MP_StartMusicPlayer:
ENDFUNCTION

FUNCTION GLB_MP_PlayMusic:
IF ISMUSICPLAYING()=0 THEN PLAYMUSIC "Media/music.mp3",TRUE
ENDFUNCTION

FUNCTION GLB_MP_StopMusic:
STOPMUSIC
ENDFUNCTION

FUNCTION GLB_MP_NextTitle:
ENDFUNCTION

FUNCTION GLB_MP_PreviousTitle:
ENDFUNCTION

FUNCTION GLB_MP_isPlaying:
RETURN FALSE
ENDFUNCTION
?ENDIF

FUNCTION GLBMusicDummy:

ENDFUNCTION
Then in your main code use these commands:-
GLB_MP_StartMusicPlayer()     This brings up the iPod music selection screen. You can select as many songs as you like
GLB_MP_PlayMusic()                This plays the music you selected earlier
GLB_MP_StopMusic()               This stops the music

Also when you start the game again, assuming it carries on from where it left off, then do this:-
Code: (glbasic) [Select]
SUB GLB_ON_RESUME: //Happens when gets loaded again
IF musicon=1 THEN GLB_MP_PlayMusic()
ENDSUB
Note musicon is just a variable I use to know I selected music in the first place.

This all seems to work on my iPhone game that is on the app store. It is Rotaslider if you want to see it working (free version availble), just select music option in options menu. Music starts when you go back to main menu.

Cheers
Title: Re: iPhone - Play while hear his own music
Post by: michael on 2011-Oct-14
has anyone try this code with ios 5??? since I have update there is no sound more playing :rant:
any idea ?