07-31-2008 10:00 AM
Hi,
I am creating one media player application for Blackberry Devices with JDE 4.2 and i am trying to play a MP3 song file available on Server. But i am getting http connection time out exception. The same code is working for MIDI type of audio file with JDE 4.0
Following is code snap:
try {
String url = "http://~URL~/Data/AAAAA.mp3";
//String url = "http://~URL~/Data/AAAAA.mid";
// Above commented code works perfectly with JDE 4.0
HttpConnection httpConnection = (HttpConnection) Connector
.open(url);
InputStream inputStream = httpConnection.openInputStream();
String types[] = Manager.getSupportedContentTypes(null);
for (int i = 0; i < types.length; i++) {
System.out.println(types[i]);
}
Player p = Manager.createPlayer(inputStream, "audio/midi");
p.addPlayerListener(this);
p.realize();
p.prefetch();
p.start();
} catch (IOException ioEx) {
Status.show(ioEx.getMessage());
} catch (MediaException meEx) {
Status.show("Media Exception");
meEx.printStackTrace();
} catch (Exception e) {
Status.show("Exception");
}
Please provide me suggetions to remove this exception.
Thanks,
Shiva
07-31-2008 12:13 PM
Check your MIME type "audio/midi" is not correct for playing an mp3....
try "audio/mpeg"
Daniel
08-01-2008 12:14 AM - edited 08-01-2008 12:24 AM
Thanks for ur response
I have configure audio/mpeg for running MP3 file and audio/mid for midi file. I tried to run the application with MDS and it works only for audio/mid. I am using JDE 4.2 currenlty, but i dont know how to configure MDS for it. Let me know how to configure MDS for playing MP3 file from server.
Thanks in advnaces for your support.
Thanks
Shiva
08-01-2008 01:03 AM
Mark Sohm had recommended the following link to some one else for figuring out this kind of connection issue...
I pass it on here...
Question: If you don't use the MDS simulator are you able to play the mp3 directly from the URL?
Do you have any new code snippets to look at?
Daniel
08-01-2008 01:04 AM
This was the original post I found it in...
08-01-2008 01:36 AM
I've never supported anything that far back, but I'm wondering if RIM had introduced support for MP3 by 4.0 - I thought that was a relatively recent introduction.
Could you perhaps try http://www.falseflag.com/blackberry/pac/App.ja
08-01-2008 02:00 AM
I am able to play MP3 song by full url in all audio players available, but i am not able to access the same url for MP3 file through my blackberry application. I dont have actual device to test the application, for the testing purpose i am using MDS simulator with JDE 4.0 which does not support audio/mpeg.
Currently I am using JDE 4.2(does not contain MDS) so i am using the MDS simulator of JDE 4.0 and eclipse 3.3.1.1 plugin. With this setup i cant able to run the application.
It gives a connection timeout exception
Please view the code below.
try {
String url ="http://url~/A.mp3"
HttpConnection httpConnection = (HttpConnection) Connector
.open(url);
InputStream inputStream = httpConnection.openInputStream();
String types[] = Manager.getSupportedContentTypes(null);
for (int i = 0; i < types.length; i++) {
System.out.println(types[i]);
}
Player p = Manager.createPlayer(inputStream, "audio/mpeg");
p.addPlayerListener(this);
p.realize();
p.prefetch();
p.start();
} catch (IOException ioEx) {
Status.show(ioEx.getMessage());
} catch (MediaException meEx) {
Status.show("Media Exception");
meEx.printStackTrace();
} catch (Exception e) {
Status.show("Exception");
}
Thanks
08-01-2008 09:46 AM
You should start with a newer version of MDS. 4.1 has an MDS which is what I normally use for 4.2 and 4.2.1 (and also with 4.0). We haven't had any problems with transferring audio/mpeg files over it but I have not tested your exact scenario.
I'm not sure if you have already looked at this but here are some useful links on the subject of audio types:
Supported Media Types:
http://www.blackberry.com/btsc/articles/216/KB0541
Knowledge Base Article on Streaming Audio: