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: 178
Registered: ‎08-26-2009
My Device: Not Specified
Accepted Solution

network issue with regard to streaming

Could someone tell me what I'm doing wrong? When I click stop, the download stream doesn't stop downloading. This happens on the device and not the simulator.

 

 

 

public class MusicPlayer extends MainScreen implements FieldChangeListener {
	
	HttpConnection http; 
	SharedInputStream readAhead1;
	Player _player;
	ButtonField stop;
	
	MusicPlayer(){
		stop = new ButtonField("Stop", ButtonField.CONSUME_CLICK);		
		stop.setChangeListener(this);
		add(stop);
		try {
			
			http = (HttpConnection) Connector.open
			( "http://www.dg.deathcompany.org/blackberrytest/ATB-DontStop.mp3"+";interface=wifi",Connector.READ_WRITE, true);
			http.setRequestProperty("Connection", "KeepAlive");
			
			if (http.getResponseCode() != HttpConnection.HTTP_OK && http.getResponseCode() != 206) 
			{ 
				int responseCode = http.getResponseCode(); 
				System.out.println("Http not ok:" + responseCode );
			}
			readAhead1 = SharedInputStream.getSharedInputStream(http.openInputStream());
			
			try {
				_player = Manager.createPlayer(readAhead1, "audio/mpeg");					
			} catch (MediaException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}									
			try {
				_player.prefetch();
				_player.realize();
				_player.start();				
				
			} catch (MediaException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}				

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}



public void fieldChanged(Field field, int context) { try{ if(_player != null){ _player.stop(); _player.deallocate(); _player.close(); } if(readAhead1 !=null){ readAhead1.close(); readAhead1 = null; } if(http != null){ http.close(); } }catch(Exception e){ } } }

 

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: network issue with regard to streaming

Might be related to issue JAVAAPI-125 in the Developer Issue Tracker.

Developer
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: network issue with regard to streaming

[ Edited ]

Could you be kind enough to provide me with a link of some sort? I have been wrecking my brains out for the past 2 days...

Highlighted
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: network issue with regard to streaming

https://www.blackberry.com/jira/browse/JAVAAPI-125 -- you need to log in using your Dev Zone e-mail address and password.

Developer
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: network issue with regard to streaming

[ Edited ]

sighhhhhh, and all this time I thought it was a problem with my code Smiley Sad I kept trying different methods. Thank you so much