Hi all,
I have the following code, which is extremely simple but fails to play the audio. I've tried it under 2 emulators and a real device, and with both wav and mp3 files.
Both test files worked (with HTTP streaming) on my PC with VLC player.
package testest;
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class TheMid extends MIDlet implements Runnable {
public TheMid() {}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {}
protected void pauseApp() {}
protected void startApp() throws MIDletStateChangeException {
new Thread(this).start();
}
public void run() {
try {
// sorry for the mangled urls, it complained about me posting links
// replace dashes with colon-slash-slash or with slashes. leave underscores alone
// and sorry for the weird content of the audio files :rolleyes:
String test_wav = "http---www-archive-org-download-BenWillemsTestTestwav-Test.wav";
String test_mp3 = "http---www-archive-org-download-ezraLoudmouthSomethingtoSay7_3-episode_7.mp3";
HttpConnection con = (HttpConnection)Connector.open(test_mp3); // or test_wav
InputStream in = con.openInputStream();
Player player = Manager.createPlayer(in, "audio/mpeg"); // or audio/x-wav, or audio/wav, or audio/mp3 to be safe
player.realize();
player.prefetch();
player.start();
} catch(Exception e) {
Form f = new Form("Exception!");
f.append("e.Type: " + e.getClass().getName());
f.append("e.Msg: " + e.getMessage());
Display.getDisplay(this).setCurrent(f);
}
}
}
Sun's and Sprint's emulators appear to be basically the same. They fail on wav with:
MediaException -- Failed to realize Player: premature end of stream
And they don't support mp3 so they fail on "audio/mpeg"
And my real device, a LG LX550 or Fusic, fails on both files and greets me with:
MediaException -- Could not read input stream (empty)
And of course they all failed with the obvious error for the incorrect mime types. I only tested those for the sake of completion.
Hope this is enough info and sorry for the novel. Anyone have any ideas? Thanks in advance
