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
Highlighted
New Developer
Posts: 46
Registered: ‎12-16-2010
My Device: Not Specified

Audio cuts out when I try to play using player.

Hello guys, in the app I am developing I download audio from a server and then play it back using the player class. Now the strange thing is this works 100% correctly in the emulator, but on the phone itself (8350i Nextel model) it downloads the same number of bytes but it cuts out the audio playing like about 95% though the audio and I can't detect that the audio ended through my player listener.

 

Here is my code for the downloader.

try
{
    FileConnection dest = (FileConnection)Connector.open("file:///store/home/user/documents/voting.mp3",Connector.READ_WRITE);

if (!dest.exists()) {
dest.create();
}
else
{
 dest.delete();
 dest.create();   
}
OutputStream outStream = dest.openOutputStream();
HttpConnection connection = null;
InputStream inputStream = null;

connection = (HttpConnection) Connector.open("http://server.mp3", Connector.READ_WRITE, true); //Can't give out real server link.
inputStream = connection.openInputStream();


byte[] Buffer = new byte[1024];
int temp = 0;
int amount = 0;
int length = (int)connection.getLength();
while ((amount != length)) {
temp = inputStream.read(Buffer);
amount = amount + temp; 
outStream.write(Buffer);

System.out.println(amount);
}


connection.close();
outStream.close();


}
catch (Exception e){

}

 

 

and for the player:

 

String file = "file:///store/home/user/documents/voting.mp3" ;
myPlayer = Manager.createPlayer(file);
myPlayer.realize();
myPlayer.prefetch();
myPlayer.setLoopCount(1);
vc = (VolumeControl)
myPlayer.getControl("VolumeControl");
vc.setLevel(25);

VotingListener v = new VotingListener();//Player Listener myPlayer.addPlayerListener(v);
myPlayer.start();

} catch (Exception e) {

System.out.println(e.toString());
}

 

 

I am kinda clueless on why it would work exactly correctly through the emulator but not on the actual phone itself. Anyone got any ideas?

 

Thanks