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

Recurring media error

[ Edited ]

I have this problem that seems to be there no matter how much I change the code. I have tried absotely everything I could possibly think of with no avail.

 

I'm building an MP3 streaming application, I'm using a JSON stream to obtain the URL and the thumbnail of album art.

 

I first initialse all the UI components, and then retrieve the URL and start the player.

 

 

public MusicPlayer(JSONObject currTrack, JSONArray trackDetails){
.......
StartPlayer();
}
public void StartPlayer(){
       _playerThread = new PlayerThread();
        _playerThread.start();    
        
}

 

The player thread initialises an HTTP request and SharedInputStream which is a private variable of the class. And all is good, the music plays.

 

The user clicks the next button,

 

So I load the URI variable, change the album art and close all the streams.

 

 

if (_player != null)
        {
            _player.stop();
            _player.deallocate();
            _player = null;
        }        
        
        if(readAhead1 != null){
        	readAhead1.close();
        	readAhead1 = null;
        }
        
        if(http != null){
        	http.close();
        	http = null;        	
        }
            
    }

 

 

And then it starts playing the next song. BUT when I exit the application, the song stops playing, but the phone shows that that it's still downloading something (even though I've closed all the streams and player).

 

HELP!

 

 

 

 

 

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

Re: Recurring media error

I have a feeling it's to do with this,

 

 

http.close();

 

 

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

Re: Recurring media error

If I remove,

 

http.close();

 

the download process stops but when I switch to a new track the music doesn't play(I think this is because the http stream is still open). Can anyone give me an idea, how to work around this?