×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Shoutcasting Internet Radio Streaming and playing Mp3 Files in J2me Midlet(Java):

    Hi
    Can you pls.. once check my Source Code,Is this way to stream Shoutcast Internet Radio??
    If not give me Suggestions
    This is my source code:I am facing 11 Error in HttpOperation Exception
    public class Httpconnection extends MIDlet {
    public void startApp() {
    connection = (HttpConnection) Connector.open( "http://38.101.195.5:9156");
    dataIn = connection.openDataInputStream();
    byte[] buffer = new byte[1024];
    int read = -1;
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    while ((read = dataIn.read(buffer)) >= 0) {
    byteout.write(buffer, 0, read);}
    dataIn.close();
    connection.close();
    ByteArrayInputStream byteIn =
    new ByteArrayInputStream(byteout.toByteArray());
    Player p = Manager.createPlayer(byteIn, "audio/mpeg");
    p.start();
    Regards:
    Pavan
    Email:pavankumarragi@gmail.com

  2. #2
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Internet Radio Streaming and playing Mp3 using J2me Midlet(Java):

    Hi
    Can you pls.. once check my Source Code,Is this way to stream Shoutcast Internet Radio??
    If not give me Suggestions
    This is my source code:I am facing 11 Error in HttpOperation Exception
    public class Httpconnection extends MIDlet {
    public void startApp() {
    connection = (HttpConnection) Connector.open( "http://38.101.195.5:9156");
    dataIn = connection.openDataInputStream();//Here I am facing 11 Error in HttpOperation Exception

    How can we open the Stream?

  3. #3
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: Internet Radio Streaming and playing Mp3 using J2me Midlet(Java):

    Hi pavanragi,

    Here is the explanation for the error:

    java.io.IOException: 11-Error in HTTP operation means “Malformed data received (headers or body)”

    I think shoutcast server complaining about your request.

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Shoutcasting Internet Radio Streaming and playing Mp3 Files in J2me Midlet(Java):

    Hi pavanragi,

    dataIn = connection.openDataInputStream();//Here I am facing 11 Error in HttpOperation Exception

    How can we open the Stream?
    This is the correct way of opening a stream. Your problem is the URL. If you try to replace it with another standard http address, you will notice that you won't receive an exception any more.
    Also regarding media streaming, you would need to set the streamable parameter in the URL to true. Please find more information here:
    http://www.developer.nokia.com/Resou...streaming.html

  5. #5
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Shoutcasting Internet Radio Streaming and playing Mp3 Files in J2me Midlet(Java):

    Hi pavanragi,

    Can you try to play an mp3 over http with this code?

    Code:
    import java.io.IOException;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    
    public class Mp3overHTTP 
        extends MIDlet
        implements CommandListener, Runnable {
    
        Form mainForm;
        Command playCommand = new Command("Play", Command.OK, 0);
        Command exitCommand = new Command("Exit", Command.EXIT, 0); 
        Thread thread;
        
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
            // TODO Auto-generated method stub
        }
    
        protected void pauseApp() {
            // TODO Auto-generated method stub
        }
    
        protected void startApp() throws MIDletStateChangeException {
            mainForm = new Form("Mp3 over HTTP");
            Display.getDisplay(this).setCurrent(mainForm);
            mainForm.addCommand(playCommand);
            mainForm.addCommand(exitCommand);
            mainForm.setCommandListener(this);        
        }
    
        public void commandAction(Command c, Displayable arg1) {
            if( c == playCommand) {
                thread = new Thread(this);
                thread.start();
            }
            
            if(c == exitCommand) {
                notifyDestroyed();
            }
        }
    
        public void run() {
            Player player;
            try {
                player = Manager.createPlayer("http://tonycuffe.com/mp3/pipershut_lo.mp3");
                player.realize();
                player.start();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (MediaException e) {
                e.printStackTrace();
            }
        }
    }
    Let us know if that solves your issue.

Similar Threads

  1. Streaming youtube videos on j2me MIDlet(java)
    By pavanragi in forum General Development Questions
    Replies: 2
    Last Post: 2012-08-12, 22:06
  2. Streaming youtube videos on j2me MIDlet(java)
    By pavanragi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2012-07-30, 00:27
  3. Adding streaming WMA support to S60 Internet Radio application
    By unpaiktable in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2010-06-06, 22:20
  4. Replies: 1
    Last Post: 2008-08-14, 13:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×