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

network thread issue

When I disconnect the stream from which the media is reading, the stream doesn't stop downloading, I think this is due to the initial buffer. It works perfectly with wifi, except EDGE. I'm using the LimitedRateStreamingSource, with a data source.

 

public void run()
        {
            try
            {
                byte[] data = new byte[READ_CHUNK];
                int len = 0;

                //Until we reach the end of the file.
                while (-1 != (len = readAhead.read(data)))
                {
                	if (_stop)
                    {   
                        System.out.println("Thread stoppped");
                    	setThreadStopped(true);
                        return;
                    }
                    _totalRead += len;
                            
                    updateLoadStatus(_totalRead);
                    if (_stop)
                    {   
                        System.out.println("Thread stoppped");
                    	setThreadStopped(true);
                        return;
                    }                    
                    updateProgressBar(_totalRead);
                    if (_stop)
                    {   
                        System.out.println("Thread stoppped");
                    	setThreadStopped(true);
                        return;
                    }
                    if (!_bufferingComplete && _totalRead > getStartBuffer())
                    {
                        //We have enough of a buffer to begin playback.
                        _bufferingComplete = true;
                        System.out.println("Initial Buffering Complete");                      
                    }
                    if (_stop)
                    {   
                        System.out.println("Thread stoppped");
                    	setThreadStopped(true);
                        return;
                    }
                }
             }
            catch (Exception e) {
					
					System.out.println("Error with regard to media stream - Limited Stream Source"+e.getMessage());				             	
            }
        }

 

 

I currently set the "stop" variable to false and then sleep the main application for about 1 second, it is only then that it stops. With edge I think the delay must be longer but then that wouldn't be really an option since it'll be bad user experience. So any ideas?

 

Note this is only on the phone and not on the simulator.