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
Regular Contributor
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

ToggleButton coding question

ToggleButton {
id: play
checked: false
onCheckedChanged : {
myApp.playSound ("anthem.wav");
}

 

 

 What i need to add so when the button goes back to off , the app stops playing the sound?

totaly new in cascades. 

 

 

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: ToggleButton coding question

Theoretically:

 

ToggleButton 
{
   id: playButton
   checked: false
   onCheckedChanged: 
      {
          if (playButton.checked)
          {
             myApp.playSound("anthem.wav");
          }
          else
          {
             myApp.stopSound();
          }
      }
}

 

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Regular Contributor
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: ToggleButton coding question

nice try but no.it is not working.

 

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: ToggleButton coding question

Hi,

 

 

The suggestion posted by suaman should fire the correct signals from the QML side, however, we cannot help you unless we know what you are calling in your routines;

 

Could you share the contents of your "playSound" and "stopSound" methods? Are you able to reach breakpoints in your stopSound routine using suaman's suggestion?

 

Martin

 

Regular Contributor
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: ToggleButton coding question

it is actually a copy of cowbell sample app.

i just add a togglebutton and i want to play the wav on changed, and stop when toggle button is unchecked. 

 

Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: ToggleButton coding question

myApp.playSound ("anthem.wav"); is a call to a C++ function named "playSound" with context property "myApp" so what do you have in your .cpp file and .hpp file(s)?  Take a look at the files in the "src" folder in cowbell sample app.

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: ToggleButton coding question