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: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Multiple statements not working in MediaPlayer -QML

Hi,

 

Below is my code:

 

attachedObjects:[
                        MediaPlayer {
                            id: audioPlayer
                            onMediaStateChanged: {
                                switch (audioPlayer.mediaState) {
                                    
                                    case 0:
                                        // Unprepared = 0.
                                        break;
                                    
                                    case 1:
                                        break;
                                    
                                    case 2:
                                        break;
                                    
                                    case 3:
                                        break;
                                    
                                    case 4:
                                        audio.imageSource = "asset:///images/audio.png";
                                        audiostatus.title = "Play";
                                        audiostatus.imageSource="asset:///actionbar/play.png" ; 
                                                                       
                                        break;
                                }
                            }
                        }
                    ]

 Here in case:4 i am setting some changes in UI, but i find only one of the statement is executing which is the first statement.

 

Did anyone came across the same scenario. 

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Multiple statements not working in MediaPlayer -QML

[ Edited ]

Solved it.

Changed the code like below....

attachedObjects:[
MediaPlayer {
id: audioPlayer
onMediaStateChanged: {
if (audioPlayer.mediaState == MediaState.Stopped) {
console.log("player Stopped");
audio.imageSource = "asset:///images/audio.png"
audiostatus.title = "Play"
audiostatus.imageSource="asset:///actionbar/play.png"

}
}
}
]