Developing a Music-Player (possible?)

Hey everyone,

for Detail, I have to develop some kind of MP3-Player, embedded in an App. The music shouldn’t stop if the App goes to Background and fetch/setup the built in Music Control… Is this possible??

I think, I sould have to use AudioManager or MediaPlayer class for Android and AVAudioPlayer or mpmusicplayercontroller for iOS.

Do you thing there is an option to handle this? I hope so, but cant imagine how… I could mind that, if it’s possible, I have to change some code lines for Adroid and iOS before compiling… But at this point, I don’t even have a idea to do it for a single platform.

I’m really looking forward for your answers, and please excuse me if it’s had to read. English is not my mother lang.

Thanks! :wink:

Personally, I’m not sure that cocos2d-x is the correct framework for this. If it were me, I would do two separate apps for each platform.

You probably can’t share much of the audio code anyway, so you would only be able to share the UI between the apps, and you will get a more native looking UI using UIKit rather than Cocos2d-x.

If you do go the cocos2d-x route, you will want to write some wrapper classes to provide a C++ interface for the native code. For iOS, you can create an Objective-C++ class that has a C++ header, and put your audio code there. For Android, I suspect you would need to create a C++ class that makes JNI calls to a java class that handles the audio.

There’s several ways you can go about forking the code. One way is to have an AudioManager base class that defines a common interface that you want to use, and then create separate subclasses for iOS and Android that implement the platform specific code. I prefer this sort of approach where possible so that you only need one platform check.

Everything is possible, it’s just a matter of complexity.

Choose a cross-platform audio engine and do some research, if it supports platform specific background tasks, which can be used to implement what you are targeting for. Binding to platform specific controls is always a task, you have to solve on your own.

Cocos2d-x is a game framework, not necessarily an app framework, so you might look for such a framework.

This depends on used the audio framework. E.g. http://superpowered.com or any other cross platform audio SDK.
The audio code would be the same for all supported frameworks.

Sounds difficult… :smiley:

Thats right…!

Of curse, but I’ve found nothing else which I can use for. Also it will be the only App where I have to handle some strange things like that. And so I can combine learning an powerfull new way to create games and apps, which I can use after finishing the current project. :wink:

I have a look at it… Its cool, but no way to do what I need (if I understand it correctly), but a very cool SDK :wink:

Thanks to all helped me out at this time! :smile:

1 Like

You just have to dig into the platform API docs. There is plenty of information out there:


How about the platform SDKs and frameworks? How about Qt?

Sure, but use the appropriate tools for your specific task.
Nail nails with a hammer, not a pliers.
Paint a picture with a brush, not a broomstick.

You want to develop some kind of MP3-Player, the SDK is a cross-platform audio SDK for playing all kinds of audio formats(including MP3), so it is exactly what you need.

Unless you don’t need audio, it’s not what you need.

Yes of curse, but I cant find anything to the built in soundcontrolls of the devices. But by the way, I’ve testet the apk which they provide and it runs also in Background. Thats great, but not all i need (or do miss understand some feature?)

But THANK YOU A LOT, showing me this SDK.

Look at the provided links. You have to capture the control’s callbacks and react to them accordingly. You implement the audio stuff with the help of the SDK in those callbacks.

Oh, sorry, for sure… Im so thankful, that you helped me out with this! So my last big quest is to check how I use (wrap) the ObjectiveC and/or Java into the App… :smiley: But this seems to be an other task or question (if I won’t find anything about it).

And thanks again, for helping a newbee like me :wink:

There was a person here doing it: PXL Player [Android][Music]

a very cool app… I really like it and it’s a good style combi with the dot view case. But there is one litte prowblem with it. He creates a new notify, where you can control your music from. But in my mind it’s not possible for iOS.

But a very cool hint. If I will find an solution, I will post it here.