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

Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various
Accepted Solution

How to control MediaPlayer volume?

bb:multimedia::MediaPlayer has all the functionality to load, play, pause the music, but I could not find anything that could control the volume.


Obviously one can adjust the volume for the entire device, but is there a way to adjust the volume for just that object? 

For example - if one has background music playing in an app - it would be nice to allow the user to adjust the volume of it.


Posts: 127
Registered: ‎02-27-2012
My Device: Bold
My Carrier: Rogers

Re: How to control MediaPlayer volume?

Hello djogon,

This is definitely a valid use case. However, the Qt MediaPlayer API (QML, Qt/C++), so far, has mainly been designed for simple multimedia applications, for audio & video consumption (local or streaming). 

This functionality is currently feasible through the low level C API only; through mmrenderer:

That is, if you were to implement your use case, you would have to implement the playback using the C API and make wrapper classes to communicate with the the Cascades UI elements.

The function to control the volume, through a mmrenderer context (C API) is documented here:




The best place to start would be to look at some of the mmrenderer native sample apps, while scanning some of the high level tutorials and documentation (pasted below):


* Video playback sample app - code and tutorial with C API:






* PlayAudio sample app: https://github.com/blackberry/NDK-Samples/tree/next/PlayAudio



To wrap C/C++ API into QObjects and communicate with the QML UI elements, if you haven't come across this already, there are other sample apps which shows how to do that. Like this one:


* Kakel, Cascades sample app: https://github.com/blackberry/Cascades-Samples/blob/master/kakel/src/kakelapp.h



Some relevant documentation links of mmrenderer:



* http://developer.blackberry.com/native/beta/reference/mmrenderer_libref/topic/mm-renderer_client_api...


* http://developer.blackberry.com/native/beta/documentation/com.qnx.doc.mme.mmrenderer/topic/about.htm...



I will try to convince the API team to include this functionality in the Qt MediaPlayer API as well (for future OS releases). If you can file a feature request through the developer issue tracker, that would definitely help as well. (obviously, the more people asking for a API feature - the higher the chances).

Hope at least some of this helps.





Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various

Re: How to control MediaPlayer volume?

Thanks as always Rashid - your posts have always been complete and full of insight. I think I will use OpenAL for now since I have that part working already - I will convert my mp3's to wav files which will increase the size of the app.


I logged a feature request here



Anyone looking for volume control in MediaPlayback class - please vote for this issue.


Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: How to control MediaPlayer volume?

The MediaPlayer class has a setVolume() method in documentation, but it simply does not work:






I have two MediaPlayer instances in my QML, and need to control their volumes seperately. I'd like to get info how I can accomplish that. I can access them via "findChild()" method in C++, but don't know how to call the core C API methods on them. I guess that I would need "wrapper" classes. Any sample or hint would be very helpful. Thanks.

Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: How to control MediaPlayer volume?

Hi burrak, i have verified the setVolume method of the MediaPlayer class works and provided you with sample code in the reference forum post. Hope that helps!


Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker