greatwitenorth
greatwitenorth

Reputation: 2401

Ionic music app playing multiple songs on Android

I'm building an android music app using Ionic. I'm using the standard HTML5 audio object for control and playing of a song. I'm having issues with making other audio stop when my app starts playing music.

For example if I go to a web browser and start playing an audio file from a website, then go to my app and play a song, the website audio continues to play under the apps music. I was under the impression Android was only to allow one audio stream to play at a time. Is there a setting that will prevent this from happening?

I also notice when I play my music, then go to an app like Rdio that Rdio will stop my music playing when I start a song in that app. But if I start playing music in Rdio, then go to my app and play music, two songs will be playing at once.

Upvotes: 0

Views: 1710

Answers (1)

arielf
arielf

Reputation: 401

Have you considered using the Cordova Media plugin with Ionic instead of HTML5 Audio? You can take advantage of Android native media player.

I built an audio player module for Ionic on top of that plugin. It basically creates a UI to interact with the underlying plugin. Check it out if you're interested: https://github.com/arielfaur/ionic-audio

If you prefer to keep it simple you can simply add the Cordova Media plugin and call it from your controllers/directives. It is really easy to use! https://github.com/apache/cordova-plugin-media

Upvotes: 1

Related Questions