BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-11-2010, 12:24 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Location: Sri Lanka
Model: 9000
PIN: N/A
Carrier: Software Engineer
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Blackberry Implement audio player

Please Login to Remove!

Hi,

I am developing an application which let users to hear songs online. And I used Blackberry Player and Manager APIs. My application works fine and I can play songs. Now I wan't to add more controls to it. As an example I want pause, play songs. Mute the sound, Control the volume. Display the progress of the play back. Display the current time position of the song like that. I started research on that. And I tried to do that with PlayerListener. But unfortunately all the time I am getting IllegalStateException. So I can't go ahead with that research.

As a help can someone please tell me how can I implement above kind of controls for a player. Appreciate if someone can post a sample code to do that. Further I will put my playback source code here.


public void run() { try { p = Manager.createPlayer(requestedSong + SystemSettings.strNetwork); p.setLoopCount(1); p.start(); } catch (IOException ioe) { } catch (MediaException me) { } }

public void run()
{
try
{
p = Manager.createPlayer(strSongURL);
p.setLoopCount(1);
p.start();
}
catch (IOException ioe)
{ }
catch (MediaException me)
{ }
}

Thank you very much.

Prasad
Offline  
Old 05-11-2010, 12:55 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 9000
Carrier: Airtel
Posts: 81
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the sample code as it is posted from
Advanced blackberry development book

Code:
import javax.microedition.media.*;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.component.LabelField;
public class WatchdogListener implements PlayerListener
{
private LabelField status;
private Screen screen;
public WatchdogListener(LabelField status, Screen screen)
{
this.status = status;
this.screen = screen;
}
public void playerUpdate(Player player, String event, Object data)
{
if (event.equals(PlayerListener.BUFFERING_STARTED))
{
status.setText("Buffering, please wait.");
}
else if (event.equals(PlayerListener.BUFFERING_STOPPED))
{
status.setText("Buffer complete.");
}
else if (event.equals(PlayerListener.STARTED))
{
status.setText("Playing.");
}
else if (event.equals(PlayerListener.STOPPED))
{
status.setText("Stopped.");
}
else if (event.equals(PlayerListener.ERROR))
{
status.setText("Encountered error: " + data);
}
else if (event.equals(PlayerListener.END_OF_MEDIA))
{
screen.close();
}
else
{
status.setText (event + ":" + data);
}
}
}
__________________
blog.vimviv.com
Offline  
Old 05-11-2010, 06:31 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Location: Sri Lanka
Model: 9000
PIN: N/A
Carrier: Software Engineer
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks friend,

It works. The error gone.

Now I want to control the audio as I mentioned. Is there any source available.

Thank you.

Prasad
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.