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

Native Development

Reply
Developer
JoeQXS
Posts: 18
Registered: ‎02-13-2014
My Device: Z10 STL-003
Accepted Solution

MediaKeyWatchers are blocking volume changes.

I'm using MediaKeyWatcher to detect when the volume keys are pressed to trigger a function that grabs the current sound level to see if the volume is muted. It detects keypresses just fine, but it blocks the keys from actually changing the system volume. A possible work around is to change the volume manually, but then I lose the indicator.

 

If anyone could let me know how to use the MediaKeyWatcher without blocking volume changes I would really appreciate it.

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: MediaKeyWatchers are blocking volume changes.

[ Edited ]

This solution is simple but not very obvious, I previously asked for them to make this a little less chaotic(seems nothing was done(some(JSanders) would say i'm mean for saying that)), the documentation doesn't even describe that this will take over the users device in undesireable ways or how to fix it.  & B4BB requires the use of these keys in many cases.

 

You'll need to dynamically create your  MediaKeyWatcher by putting it in a component definition.

 

After that you can create the componentdefinition when your app is fullscreen, then as your application goes thumbnailed you need to destroy the component definition.  Then users will be able to use the volume keys when your app is minimized.

 

I will try to post a few code snippets to better demonstrate.

 

EDIT: It seems the documentation has been adjusted slightly to hint that you can use a component definition however they don't describe the process.

Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: MediaKeyWatchers are blocking volume changes.


slashkyle wrote:

This solution is simple but not very obvious, I previously asked for them to make this a little less chaotic(seems nothing was done(some(JSanders) would say i'm mean for saying that)), the documentation doesn't even describe that this will take over the users device in undesireable ways.  & B4BB requires the use of these keys in many cases.

 

You'll need to dynamically create your  MediaKeyWatcher by putting it in a component definition.

 

After that you can create the componentdefinition when your app is fullscreen, then as your application goes thumbnailed you need to destroy the component definition.  Then users will be able to use the volume keys when your app is minimized.

 

I will try to post a few code snippets to better demonstrate.


This doesn't work if you want your app globally to handle the volume key. eg: running in the background

 

When you are app is done then just disconnect the listener.

 

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: MediaKeyWatchers are blocking volume changes.

If you need the media keys when your app is not fullscreen it could be possible to use the MediaPlayer to query the volume level and adjust it based on which button was pressed I have not done this so I'm not certain if that will work.

Developer
JoeQXS
Posts: 18
Registered: ‎02-13-2014
My Device: Z10 STL-003

Re: MediaKeyWatchers are blocking volume changes.

[ Edited ]

I only need the mediakeys when the app is fullscreen, but I also need the media keys to still work with their default functions. I can change the volume of the device manually with a command but then I lose the indicator of what level the volume is at.

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: MediaKeyWatchers are blocking volume changes.

[ Edited ]

There is no pre-built solution to accomodate for this. as long as you have a media key connected it will override the volume functionality.

 

To get the indicator, you could create it yourself and show it for a few seconds.... lots of work for something very simple but it would make for a nice touch to your app =)

 

 

Alternatively you could request this feature in jira and maybe someday they will accomdate.

 

https://www.blackberry.com/jira/secure/Dashboard.jspa

 

Developer
JoeQXS
Posts: 18
Registered: ‎02-13-2014
My Device: Z10 STL-003

Re: MediaKeyWatchers are blocking volume changes.

Thats too bad, but thanks for telling me. I'll just have to find another way to check for volume changes.