03-30-2011 02:20 PM
I'm making an app that used the Blackberry Player library, and I run it on a seperate thread. I also do HTTP requests within my app for different things. My problem is that even though the player is on its own thread, it blocks all my HTTP requests, so the program will hang until the song ends (if the user tries to access a different screen that uses a new HTTP request). Anyone any idea why? I use the Blackberry Simulator with the MDS simulator. Unfortunately I can't try it on my phone, but I can't see why that'd make a difference.
03-30-2011 02:42 PM
You should never put a HttpConnection in the event thread because it will block everything until it completes. Try putting all of them in their own threads and see if that fixes your problem.
03-31-2011 09:10 AM
The problem is not that the UI freezes until it completes, rather that the request never completes (though it would were the player thread not running). I've moved the HTTP request to a separate thread but it still does the same thing. Any more ideas? It's like theres a limit to one HTTP request thread or something.
03-31-2011 09:13 AM
Make sure the server you connect to is actually available.
03-31-2011 09:19 AM
player = Manager.createPlayer(url);
In a method in a PlayerThread, which does this when it is started.
And for the actual HTTP request (which is definitely connectable, as it works as soon as the song finishes):
c = HttpUtils.makeHttpConnection(url, null, null, 0);
Which is also in it's own thread.
03-31-2011 09:22 AM
There isn't a HttpUtils class. Tell us what does HttpUtils.makeHttpConnection do?
03-31-2011 10:17 AM
To answer an earlier question, connection limits are documented here:
I would recommend a download server, a single Thread than handles all the downloads, rather than initiating a Thread for each download.