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: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

StreamingPlayer - ConnectionClosedException: Stream closed

Dear BlackBerry Developers,

 

I am developing a streaming radio player application. I can connect to the datasource and play streaming music, but I am getting intermittent error "net.rim.device.api.io.ConnectionClosedException: Stream closed". After playing some time, generally no less than 20 minutes, I am getting this error and the music stops. I am using the StreamingPlayer implementation in the Knowledge Base article, Streaming media – Start to finish.

 

Here's the info that might be helpful:

 

In debug console:

[0.0] Tunnel id=1mode=FG already referenced by process=calmeski(183)
[0.0] MP: h=0,s=PL: mStat: 0
[0.0] MP: h=0,s=PL: +mErr
[0.0] MP: h=0,s=PL: -mErr
[0.0] Media:e:MdEr:3MP: h=0,s=PL: +unld(183):37
[0.0] MP: h=0,s=PL: -> UG
[0.0] MN: unload0(0)=2 pauseHandle=0
[0.0] MN: unload0(0) (clearing active pause)
[0.0] MP: h=0,s=UG: +unlC
[0.0] MN: finalize0(0)
[0.0] MP: h=0,s=UG: -> UD
[0.0] MP: h=0,s=UD: -unlC
[0.0] MP: h=0,s=UD: -unld
[0.0] AR: remove source 13
[0.0] AR: setAudioMode 32
[0.0] Exception occured ...................net.rim.device.api.io.ConnectionClosedException: Stream closed
[0.0] MN: MEDIA_STOPPED received
[0.0] MN: handle=0 staticsHandle=0
[0.0] [SREAM] releasing buffer [index: 0] [handle: 1799]

 

I need help. Thanks in advance.

 

 

Best regards,

 

Burak

Developer
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: StreamingPlayer - ConnectionClosedException: Stream closed

I'm using following code in StreaminPlayer.java:

 

 /************************* Downloader Thread *************************/

        private class Downloader extends Thread{                
                public void run(){
                        downloadStopped = false;
                        int len = 0;
                        log(0, "DownloadThread - started");
                        try {                           
                                byte[] data = new byte[DOWNLOAD_CHUNK];
                                //int len = 0;
                                System.out.print("Flushing Output Stream...");
                                bufferOStream.flush();      //partha
                                System.out.print("Completed");
                                notifyFeedPaused(0);
                                                               
                                while (-1 != (len = mediaIStream.read(data))) {
                                    
                                        log(0, "DownloadThread - read " + len);
                                        if (stopDownload){
                                                downloadStopped = true;                                                 
                                                log(0, "DownloadThread - stopped");
                                                return;                                         
                                        }
                                        synchronized(mediaIStream){                                             
                                                                                        
                                                byte[] preProcessed = notifyPreprocessData(data, 0, len);
                                                
                                                if(preProcessed!=null){
                                                        log(1, "Writing preProcessed bytes: " + preProcessed.length + "..");
                                                        
                                                        bufferOStream.write(preProcessed, 0, preProcessed.length);
                                                        
                                                        bufferEndsAt += preProcessed.length;
                                                        log(1, "DownloadThread - preProcessed bytes written: " + preProcessed.length);                                          
                                                } else{
                                                        log(1, "Writing bytes: " + len + "..");
                                                       
                                                        bufferOStream.write(data, 0, len);  
                                                        
                                                        bufferEndsAt += len;
                                                        log(1, "DownloadThread - bytes written: " + len);
                                                }
                                                
                                                notifyBufferStatusChanged(bufferStartsAt, buffer.getSize() - buffer.getSpaceLeft());                                    
                                                
                                                
                                                totalDownload += len;
                                                notifyDownloadStatusUpdated(totalDownload);                                             
                                                
                                                if (!initialBufferingComplete && totalDownload >= initialBuffer) {                                                      
                                                        initialBufferingComplete = true;                                                
                                                        log(0, "DownloadThread - initialBuffering complete");
                                                        notifyInitialBufferCompleted(totalDownload);
                                                }
                                        }
                                }
                                
                                log(0, "**** Stream bitti mi yani?");
                                
                                if(!initialBufferingComplete){
                                        initialBufferingComplete = true;
                                        notifyInitialBufferCompleted(totalDownload);
                                }
                                downloadComplete = true;
                                downloadStopped = true;
                                log(0, "DownloadThread - download stopped.");
                                log(0, "DownloadThread - download complete.");
                        }
                        
                        catch (Exception e)
                        {
                            //BK
                            log(0, "***son*** DownloadThread - read " + len);
                            System.out.println("***calmeski - burak**** Exception occured ..................."+e);   
                        }
                        
                        catch (Throwable e) {
                                downloadStopped = true;
                                log(0, "DownloadThread - download stopped due to an Exception - "+e.toString());                                
                                
                                if(!reconnectInProgress && !userClose && !userSeek){
                                        synchronized(connectionLock){
                                                notifyStreamingError(StreamingListener.ERROR_DOWNLOADING);
                                                dataDiscarded = false;
                                                log(0, "DownloadThread - Trying to resume connection..");
                                                streamingPlayer.resumeDownload();       
                                                log(0, "DownloadThread - connected.. download resumed.");
                                        }
                                }
                        }
                }
        }
        
        /************************* End of Downloader Thread *************************/

 

 

Sometimes, the exception is caught and I'm getting the ConnectionClosedException: Stream Closed. However, again sometimes, the while loop just stops, as if it reached the end of stream. But I'm connecting to a non-stopping stream (a web radio).

 

Any help would be appreciated. I'm really stuck here. Thanks in advance,

 

 

Best regards,

 

Burak

Developer
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: StreamingPlayer - ConnectionClosedException: Stream closed

I'm stuck with this one, and really could use a helping hand... Thanks in advance...

Developer
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: StreamingPlayer - ConnectionClosedException: Stream closed

Well, it seems that nobody here worked on a live-streaming radio application...?

Visitor
Posts: 1
Registered: ‎01-14-2012
My Device: Bold 9650
My Carrier: INDOSAT

Re: StreamingPlayer - ConnectionClosedException: Stream closed

I got same problem Smiley Sad

 

 

Keep Fighting!
Contributor
Posts: 18
Registered: ‎01-10-2013
My Device: Amstrong
My Carrier: Indosat

Re: StreamingPlayer - ConnectionClosedException: Stream closed

have u found the solution.? Smiley Sad