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
djogon
Posts: 93
Registered: ‎10-29-2012
My Device: Z10
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.

 

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

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:

http://developer.blackberry.com/native/beta/reference/mmrenderer_libref/topic/mmr_api/mmr_output_par...

 

---------------------------


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:

http://developer.blackberry.com/native/beta/documentation/video_playback_overview_2006471_11.html 


https://github.com/blackberry/NDK-Samples/tree/next/VideoPlayback

 

---------------------------

 

* 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/documentation/com.qnx.doc.mme.mmrenderer/topic/arch.html


* 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.

 

Cheers,
Rashid

 

 

Developer
djogon
Posts: 93
Registered: ‎10-29-2012
My Device: Z10

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

https://www.blackberry.com/jira/browse/BBTEN-405

 

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

 

Developer
burakk
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold

Re: How to control MediaPlayer volume?

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

 

https://developer.blackberry.com/native/reference/cascades/bb__multimedia__mediaplayer.html

 

http://supportforums.blackberry.com/t5/Native-Development/How-to-Set-Media-Player-s-Volume-in-QML/m-...

 

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.

BlackBerry Development Advisor
sabdelsayed
Posts: 249
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10

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!

@SamarAbdelsayed

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