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
burakk
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
Accepted Solution

Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

Hi,

 

As I wrote in

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

 

I cannot control the volume of a MediaPlayer object using myPlayer.setVolume(). 

 

I managed to set the volume using:

void ApplicationUI::setVolume(float val)
{
	//audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, val);
	mediacontroller_volume_set_level(val);

}

 

mediacontroller_volume_set_level() method from mediacontroller.h core API library.

 

But this works on the single MediaPlayer instance I have on my QML, and I need to find a way to control multiple players' volumes. How do I set a specific MediaPlayer as "active" or "current" to call the 

 

mediacontroller_volume_set_level(val);
Developer
burakk
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

I still need help/advice on this... Thanks.

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

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

I still need help/advice on this... Thanks.

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

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

I guess that I'd need to associate the control name I got with findChild() method with the mmr_connection and mmr_context, but I am not sure how. Any help would be great. Thanks in advance.

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

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

Hi @burakk,

The *setVolume* function should work for changing the volume on each MediaPlayer instance. For example, if you have two pointers initalized:

MediaPlayer a* = new MediaPlayer(...);
MediaPlayer b* = new MediaPlayer(...);

 

....

a->setVolume(...);

b->setVolume(...);

The MediaPlayer instance is a wrapper class around the mm-renderer contexts. So if this isn't work then this might be a bug on the platform. Can you share more details as to which device (hardware model number like STL100-3) or OS version (e.g. 10.2.0.X) you are using? I am assuming you tested this with the latest OS version avaiable?

On a side note: The *setAudioManagerHandle* is supposed to be used to control the master volume of the device (after initializing the audio manager handle; passing it here and controlling the volume through audio manager functions).

https://developer.blackberry.com/native/reference/cascades/bb__multimedia__mediaplayer.html?f=mediap...


Cheers,
Rashid

Application Development Consultant | Developer Relations

BlackBerry
@surashid




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

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

Hi s_rashid,

 

I am using BlackBerry Native SDK 10.1 in 

 

QNX® Momentics® IDE for BlackBerry® 10 Native SDK

Version: 10.2.1
Build id: v201308081807

 

and testing with my device:

 

Model: BlackBerry Z10

Model Number: STL100-1

Software Release: 10.1.0.4181

 

I need to call setVolume() on each of the MediaPlayer instances in my QML, but it does not work. I am getting:

 

TypeError: Result of expression 'myPlayer.setVolume' [undefined] is not a function.

 

It neither works in QML, nor in C++.

 

 

I need to control the volumes seperately, so is setAudioManagerHandle the right method for that? Thanks. 

 

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

Re: Controlling the Volumes of Multiple MediaPlayers - mediacontroller.h Core API Library

Hi burakk,

 

Please refer to your first forum post for explanation and code snippet on how to implement what you are trying to achieve. I have verified using the "nowplaying" sample app that the setVolume method of the MediaPlayer API works as expected. Hope it 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