Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
rtholmes
Posts: 26
Registered: ‎04-21-2011
My Device: Playbook
My Carrier: N/A

Webworks audio cancels playing audio

I am using the normal HTML5 audio API to play short sound clips from my Webworks app (triggered by a timer). Unfortunately, whenever one of these audio prompts plays, it cancels any track being played by the music app, or any other app that is playing music in the background. If you press volume up/down after the sound effect has played you can see the sound effect name in the dialog as well.

 

Does anyone have a tip to prevent webworks audio from cancelling background audio?

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Webworks audio cancels playing audio

Which platform/OS version is this on? I do recall a time where we did not support multi-channel audio but it should function on BlackBerry 10 / later PlayBook builds. I'll try to dig up the point where the change occurred.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
BlackBerry Development Advisor
anzor_b
Posts: 164
Registered: ‎09-24-2012
My Device: White BlackBerry 10
My Carrier: Bell

Re: Webworks audio cancels playing audio

On BlackBerry 10 (I believe PlayBook works the same), there can only be a single audio source playing at once. By audio source I mean a single application. So the native music app is a example. So is a WebWorks app. They all hook in to the native multimedia framework, which will stop all existing audio to play the most recent one.

This is by design.

Please use plain text.
Contributor
rtholmes
Posts: 26
Registered: ‎04-21-2011
My Device: Playbook
My Carrier: N/A

Re: Webworks audio cancels playing audio

Thanks for the clarification Anzor. This really is unfortunate for any app that wants to provide an audio cue or sound effect in a context where users would also want to play music from their libraries (e.g., any kind of exercise app). Does this mean there is no way for an app then to pause any existing music, play their sound, and resume whatever was previously playing, not even with a native extension?

Please use plain text.
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Webworks audio cancels playing audio

@rtholmes Couldn't you play music files from your application itself rather then invoking the Music player. Then you wouldn't have to worry about pausing the music and restarting it.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Webworks audio cancels playing audio

If you do go about playing the user's music from within your application you'll still encounter a problem though. HTML5 audio can only play a single audio at once. You would either have to use a Flash fallback or a native sound plugin.

I think some options for this are discussed here --> http://hosting.desire2learncapture.com/RIM/1/watch/52.aspx
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
BlackBerry Development Advisor (Retired)
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold
My Carrier: Rogers

Re: Webworks audio cancels playing audio

"Only one app can make sounds at the same time" <-- This is ONLY true if the app is using the NowPlayingConnection service.

The browser app does use the NowPlayingConnection service by default - that would explain the behavour.

However, you can choose to have applications (for example, if making native extensions) where you don't hook into the NowPlayingConnection service. Multiple apps can make sounds at the same time; but not always recommended.

Please use plain text.
BlackBerry Development Advisor (Retired)
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold
My Carrier: Rogers

Re: Webworks audio cancels playing audio

As far as I know (and the web experts can correct me here as appropriate), the HTML5 audio tags are played through the browser, which ties in to the underlying multimedia platform. The browser app happens to use the NowPlayingConnection service by default, for which you are seeing this behaviour.

You can try to make a native extension for the playback of your sounds. You can do it through
a) Using BlackBerry multimedia platform API
b) OpenAl API

By default, through native apps, it doesn't tie in with the NowPlayingConnection service and you won't see this behaviour.

Cheers,

Rashid

Please use plain text.