Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-2008, 05:27 AM
Member
 
Join Date: Nov 2008
Posts: 1
Rep Power: 0
zildjohn01 is on a distinguished road
Default simple mp3 streaming
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.

Code:
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:
Code:
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:
Code:
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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
J2ME/Android Video Streaming Project mox27 Forum Lobby 4 04-06-2009 08:48 AM
Outputstream not streaming. dantestein Networking 2 03-14-2009 07:36 AM
streaming mp3 arnab321 CLDC and MIDP 1 10-11-2008 03:08 PM
video streaming anniya0n Database 1 01-24-2008 05:35 PM
PeerStream Audio Video Streaming Server 4.61 levent Java Announcements 0 07-31-2007 07:50 PM


All times are GMT +2. The time now is 09:43 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org