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
Highlighted
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK
Accepted Solution

Volume control slider

Hi,

 

I am making an app in Cascades (Momentics C++/QML) which, when a button is pressed, plays a sound effect chosen from a drop down menu.

 

For this I need a volume control slider to adjust the device media volume, like the volume control slider found in the BlackBerry music app.

 

 

However I have no idea how I am supposed to get this to work in Cascades. I know how to get a slider into the app and use it to change a value, but can't get it to change the device volume.

 

Any ideas?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Volume control slider

Yiu need to look at the NowPlayingConnection and associated class NowPlayingController...

 

http://developer.blackberry.com/native/reference/cascades/bb__multimedia__nowplayingcontroller.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Volume control slider

Thanks, I have done everything on that page but there seems to be an error.

 

Unknown symbol 'nowPlayingController'

 

I have added this to my .cpp and yet it does not recognise nowPlayingController as a variable.

#include <bb/multimedia/nowPlayingController>
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Volume control slider

It would be a capital N on the Object creation.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Volume control slider

[ Edited ]

Tried it and it still won't accept it. 

 

                Button {
                    id: volUp
                    text: "Vol Up"
                    onClicked: {
                        nowPlayingController.volumeUp();
                    }
                }
                
                Button {
                    id: volDown
                    text: "Vol Down"
                    onClicked: {
                        nowPlayingController.volumeDown();
                    }
                }

 On the nowPlayingController line I have the yellow lightbulb, persistantly telling me "Unknown symbol 'nowPlayingController'.

I tried changing the letters to capitals/non capitals in both the .qml and .cpp and still it remains :/

 

//EDIT: Is bb.multimedia 1.2 needed at the top of the QML file? I have only been able to add multimedia 1.0 since it is the only multimedia I have.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Volume control slider

Yes this is 10.2 upwards only.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Volume control slider

Re-installing Momentics. Everything on there is 10.2 yet I can't access half the 10.2 things available. Fingers crossed Smiley Happy

New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Volume control slider

[ Edited ]

Re-installed Momentics and deleted/reloaded the Native SDK 10.2.

 

Still it does not accept that nowPlayingController is a variable.

 

asset:///main.qml:270: ReferenceError: Can't find variable: nowPlayingController

 

^ This appears in the console box at the bottom when I attempt to change the volume from the device, and the lightbulb is by the nowPlayingController line in the QML code, saying it is not recognised.

 

Are there any files I need to modify for this to work?

 

So far I have added "LIBS += -lbbmultimedia" to the .pro

And "#include <bb/multimedia/NowPlayingController>" to the .cpp file

 

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Volume control slider

The error you are getting looks like a variable you have created have you declared it in the header or function?

Post your code if you think you are doing so correctly.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Volume control slider

In the example this is the id given to the attached controller have you written this correctly, i.e.

 

    attachedObjects: [
        NowPlayingConnection {
            id: nowPlayingConnection
        }
    ]

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.