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

Reply
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

How to get state of audio player?

Hi

 

 

I have an app that playes audio files. But before playing the file i need to check and make sure that the audio player is not already running/playing another audio file......

 

Can someone guide me on how i can know whether the audio player is already playing or its closed state?

 

Thanks,
Saket

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: How to get state of audio player?

 

Player.getState();

 

http://www.blackberry.com/developers/docs/5.0.0api/javax/microedition/media/Player.html

 

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Highlighted
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to get state of audio player?

Thanks for the reply,

 

 

But the getState() method is not a static method. Which means that it will give me the state of a given player instance. But the trouble i am facing is that i dont have any access to the current state of the player that has already started.....

 

Or can you tell me how i can get the current instance of a player that is already playing?

 

THanks,

Saket

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: How to get state of audio player?

[ Edited ]

If you create a reference to the Player then you can get its state. Try declaring it as a field in the class that you're using it in (unless you're using more than one. Then you'd need to have separate references for each. The other way to do it is to use PlayerListener.

 

http://www.blackberry.com/developers/docs/5.0.0api/javax/microedition/media/PlayerListener.html

 

After creating your Player or Player instances, you'd then attach the PlayerListener to it and the PlayerListener would get notified every time the state is changed.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to get state of audio player?

How do i get reference of the player which is already running before i start my app? That is exactly what i need.

 

Please let me know.

 

Thanks,

Saket

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to get state of audio player?

Hi

 

 

Can anyone please tell me how i can get the state of a instance of player that has already started running before i start my app......i need to know this bcoz, i want to make sure that the player is not playing another file before i try to play my own audio files.....

 

Thanks,

Saket