BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-11-2010, 12:24 AM   #1
prasadrajapaksha
Knows Where the Search Button Is
 
Join Date: Dec 2009
Location: Sri Lanka
Model: 9000
PIN: N/A
Carrier: Software Engineer
Posts: 21
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
vivartpandey
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 9000
Carrier: Airtel
Posts: 81
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
prasadrajapaksha
Knows Where the Search Button Is
 
Join Date: Dec 2009
Location: Sri Lanka
Model: 9000
PIN: N/A
Carrier: Software Engineer
Posts: 21
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  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Nextiva X-835 SIP Color Deskset VoIP Phone Black New In Box picture

Nextiva X-835 SIP Color Deskset VoIP Phone Black New In Box

$44.99



Polycom Vvx 601 VoIP 16 Line Business Phone 4.3

Polycom Vvx 601 VoIP 16 Line Business Phone 4.3" HD Touchscreen PoE With Stand

$28.95



Digium D40 IP Desk Phone with Stand Warranty 2-Line SIP HD VoIP Voice 1TELD040LF picture

Digium D40 IP Desk Phone with Stand Warranty 2-Line SIP HD VoIP Voice 1TELD040LF

$21.98



Vtech ErisTerminal VSP861 Touchscreen Color Desktop - Voice-Over-IP VOIP Phone picture

Vtech ErisTerminal VSP861 Touchscreen Color Desktop - Voice-Over-IP VOIP Phone

$14.99



Mitel 5330e VoIP Dual Mode Gigabit Phone - Black picture

Mitel 5330e VoIP Dual Mode Gigabit Phone - Black

$15.95



GAI-Tronics 276-002BH Behavioral Health VoIP phone -Volume Control, Indoor, PSTN picture

GAI-Tronics 276-002BH Behavioral Health VoIP phone -Volume Control, Indoor, PSTN

$179.99







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