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
Posts: 132
Registered: ‎11-06-2012
My Device: BlackBerry Passport
Accepted Solution

Get and Set the Master Volume

My app plays an mp3 file, but it depends on the master volume, Can I get the currently master volume level, reset it when the player plays and change it to the normal level later?

Highlighted
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: Get and Set the Master Volume

[ Edited ]

Hi,

 

Actually i don't know how to set volume using cascade but i have alternative way .

you can use native code

 

Try this

 

#include "applicationui.hpp"

#include <bb/cascades/QmlDocument>
#include <bps/bps.h>
#include <bps/audiomixer.h>

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	qml->setContextProperty("app", this);
	AbstractPane *root = qml->createRootObject<AbstractPane>();
	app->setScene(root);

	float val = 100; // Volume level between 0 to 100
	audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, val);
}