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
Regular Contributor
Posts: 85
Registered: ‎12-12-2011
My Device: PlayBook, Z10
My Carrier: None

how to set volume to mmrenderer audio

Hello!,

I was trying to set the volume for a sound using the mmr_* API functions, this is what I was trying:

 

char vol[MAX_PATH];
sprintf(vol, "%d", volume);
strm_dict_t *dict = strm_dict_new();
dict = strm_dict_set(dict, "volume", vol);
if (dict) mmr_output_parameters(ctxt, audio_oid, dict);

it does not work, anyone knows what is wrong or how should it be done ?

Thanks!

 

 

BovioSoft Games
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: how to set volume to mmrenderer audio

[ Edited ]

The PlayAudio sample shows how you can set the audio volume:

https://bdsc.webapps.blackberry.com/native/beta/sampleapps

 

The method this sample uses to change the volume is:

audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, float volume);

 

Regards,

Garett
@garettBeuk
--
Goodbye everybody!
Regular Contributor
Posts: 85
Registered: ‎12-12-2011
My Device: PlayBook, Z10
My Carrier: None

Re: how to set volume to mmrenderer audio

thanks, but audiomixer_set_output_level seems to change the overall volume, I like to change it just to individual sounds.

BovioSoft Games
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: how to set volume to mmrenderer audio

The code you provided for mmr worked for me, I just plugged it into the PlayAudio sample at line 150 of main.c:

 

    	strm_dict_t *dict = strm_dict_new();
    	dict = strm_dict_set(dict, "volume", "50");
    	if (dict) mmr_output_parameters(ctxt, audio_oid, dict);

 

This successfully resulted in the output audio volume being halved. I used the NDK 2.0 Beta 3.

 

Regards,

Garett
@garettBeuk
--
Goodbye everybody!
Regular Contributor
Posts: 85
Registered: ‎12-12-2011
My Device: PlayBook, Z10
My Carrier: None

Re: how to set volume to mmrenderer audio


gbeukeboom wrote:

 I used the NDK 2.0 Beta 3.

 


I'm using NDK 1.0

probably that's the reason it does not work Smiley Sad

BovioSoft Games
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: how to set volume to mmrenderer audio

PlayBook OS 2.0 is set to be released in February, it may be worthwhile to begin using NDK 2.0:

http://developer.blackberry.com/native/beta/

Garett
@garettBeuk
--
Goodbye everybody!
Regular Contributor
Posts: 85
Registered: ‎12-12-2011
My Device: PlayBook, Z10
My Carrier: None

Re: how to set volume to mmrenderer audio

I would, but I have a game almost ready to release, and I like to stick to 1.0 for a while to maximize potential user base.

 

btw, there is no way to loop audio using mmr API, is it ?, I'm surprised on that, such functionallity is a must.

 

BovioSoft Games
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: how to set volume to mmrenderer audio

You can listen for the current audio to stop then restart it:

http://supportforums.blackberry.com/t5/Native-SDK-for-BlackBerry-Tablet/Detect-Audio-Track-Has-Finis...

 

I will post back if I discover another way to do this.

 

Regards,

Garett
@garettBeuk
--
Goodbye everybody!
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: how to set volume to mmrenderer audio

I just discovered mmr_input_parameters(), you can pass parameters to tell it to repeat the same track:

https://bdsc.webapps.blackberry.com/native/beta/reference/com.qnx.doc.mme.mmrenderer/topic/mmr_api/m...

 

Cheers,

Garett
@garettBeuk
--
Goodbye everybody!
Regular Contributor
Posts: 85
Registered: ‎12-12-2011
My Device: PlayBook, Z10
My Carrier: None

Re: how to set volume to mmrenderer audio

already tried that (listen if audio stopped), but again, it seems is not available on NDK 1.0

 

the work around I might try is: just keep calling mmr_play, I noticed that once the audio starts to play, subsecuent calls to mmr_play do nothing unless the audio has finished playing, making it to start again.

 

thanks.

 

BovioSoft Games