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: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
Accepted Solution

Mediaplayer is not playing full sound using c++

Hi,

 

I am trying to play sound using mediaplayer using below code:

 

 MediaPlayer player (this);

 

          player.setSourceUrl(QDir::currentPath() + "/app/native/assets/sounds/play.mp3");

       player.play()

 

But it just play for fraction of second and then get closed.

Rujuta Trivedi
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Mediaplayer is not playing full sound using c++

Hi,
Are you creating MediaPlayer as a local variable? It will be destroyed on exit from { ... } block. Create it as a member variable instead.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: Mediaplayer is not playing full sound using c++

Thanks. I declared it as member but than created local member and was using that by mistake.:smileyhappy: Thanks

Rujuta Trivedi