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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 67
Registered: ‎11-24-2008
My Device: Not Specified
Accepted Solution

Best Practices for playing multiple sounds - one MediaPlayer or many?

Hello!

 

I am using the MediaPlayer object in QML. 

 

Problem: If I have 10 objects, and when you tap an object a sound plays... then with ONE MediaPlayer, the sound that is playing has to finish before another sound can start. (Or you can write the code to 'stop the existing sound and play another one'). Either way, you can't have a musical flurry when you tap each object.

 

Current Solution: Add a MediaPlayer component to each object, so when you tap that object, it plays its own MediaPlayer. Sounds amazing because the sounds overlap. In a game, if you are hitting objects quicker than their sound can play, this sounds great as the dings/boops/pings are nicely overlapping as they sound.

 

However I feel that this might be taking up unnecessary memory? For example if I had 100 objects, I don't think I'd want 100 MediaPlayer components attached?

 

Is there a better way to do concurrent sound in QML?

Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Best Practices for playing multiple sounds - one MediaPlayer or many?

[ Edited ]

Check this.   They used multiple simultaneous sounds with only one soundmanger.

 

https://github.com/blackberry/Presentations/tree/master/2012-BlackBerryJam-Americas/JAM09/BaDumTss

---
If you find my post helpful please "like" it and "accept as a solution"
New Developer
Posts: 67
Registered: ‎11-24-2008
My Device: Not Specified

Re: Best Practices for playing multiple sounds - one MediaPlayer or many?

Awesome. Thanks. I have implemented this. 

 

I have a question about the destructor and app cleanup, but I've started a new (more relevant) thread for that:

 

http://supportforums.blackberry.com/t5/Cascades-Development/C-App-Destructor-causes-build-error/td-p...

New Contributor
Posts: 6
Registered: ‎02-07-2013
My Device: Playbook
My Carrier: none

Re: Best Practices for playing multiple sounds - one MediaPlayer or many?

That really doesn't answer the question. The issue was on what is the best usage of the cascades MediaPlayer class to play simultaneous sounds. The code given as a reference uses OpenAL and not MediaPlayer or mmr.

To present my story: I was trying to play simultaneous sounds in my game app: gameloop music + laser guns + explosions. Using multiple MediaPlayer instances, one for each of the sounds I wanted to play, the sounds could be played in parallel, however the performance of my game was really bad after integrating the MediaPlayer code. Plus the debug console was full of tons of messages from MediaPlayer and it was hard for me to follow my own debug messages.

Conclusion: the MediaPlayer is OK as ease of use, the API is OK; however the performance was POOR for such a simple task (playing 3-4 multiple .wav sounds in parallel), which should be trivial especially for a game. It seems to me the MediaPlayer class is too bloated and should only be used to stream remote media from a server.

 

I used the OpenAL code mentioned above in the BaDumTss JAM sample and it works great; and also the code is easy to use and understand, it's just one class, SoundManager.

 

Regards,

Ionut