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

Java 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
Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel
Accepted Solution

Playing music fromBackground Application

Hello all,

I am working on Alarm application. I a want to play music from background application. But i am getting an issue implementing that. when more than one alarm is set for same time. The player is not playing music. How to overcome on it.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Playing music fromBackground Application

What problem are you seeing?  Can you give us the detail please.

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Playing music fromBackground Application

[ Edited ]

Actually i am using a screen to show a user and in that class's constructor i am playing the music file which i get from the database. I have used

ui.pushGlobalScreen(new AlarmScreen(), 1, UiEngine.GLOBAL_QUEUE);

and in the constructor of that class i am initializing the player. But this class is pushed more than one time when there is more than one alarm is set by user for that specific time. so my application crashes on mediaPlayer.prefetch(); method. i dont understand how to solve the issue.

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Playing music fromBackground Application

please help me to solve this issue .
Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Playing music fromBackground Application

@pe
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Playing music fromBackground Application

In a similar situation I used RuntimeStore to make sure that I only ever had one Media Player running at one time (I put the player in there, and then if there was one there already, I stopped it before starting my new player.  Actually my memory is failing, I might have changed the media that was being played.  Either should work.  I suspect a similar approach will work for you too. 

Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: Playing music fromBackground Application


uttamtts wrote:

Hello all,

I am working on Alarm application. I a want to play music from background application. But i am getting an issue implementing that. when more than one alarm is set for same time. The player is not playing music. How to overcome on it.



You cannot have more than ONE player active at any give time in many BBs. Some BBs, you can have at most 2.

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Playing music fromBackground Application

Thank you for reply @Peter_Strange can you elaborate it more. How does this work .
Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Playing music fromBackground Application

[ Edited ]

yeah that i know but how can i be sure that there is only one Player active . I dont have any control over the pushGlobalScreen();  it just pushing the screen one after other.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Playing music fromBackground Application

As noted, the issue is multiple players.

 

Basically the 'solution' I outlined uses RuntimeStore as a Repository for the Player, and so, if you create a new Global Screen, you can check to see if there is already a Player active and take the appropriate action.  In summary, you are using the Player as a Singleton by getting it from and putting it into RuntimeStore.

 

I'm not sure what else needs to be elaborated.  Please ask a specific question for more detail.

 

Here is a KB article that describes using RuntimeStore to manage a Singleton:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-singleton-using-the-RuntimeStore/ta...