×

Discussion Board

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

    Streaming youtube videos on j2me MIDlet(java)

    Can any one pls.. How to play youtube videos on j2me java MIDlet?
    I want to play videos from Rss Feed?

    My Input URL:
    http://teluguone.com/tmdb/videos/Chi...medy-9533.html


    Regards
    pavan

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Streaming youtube videos on j2me MIDlet(java)

    You should really tell people on what you have tried sofar, i.e. you have some code already in the other thread I moved here: http://www.developer.nokia.com/Commu...dlet%28Java%29

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

    Re: Streaming youtube videos on j2me MIDlet(java)

    Hi pavanragi,

    See discussion in other thread for playing youtube videos

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

    Re: Streaming youtube videos on j2me MIDlet(java)

    I have tried it using the following code:
    I am facing

    Exception :javax.microedition.media.MediaException: device error, pls..help me regarding this

    Source Code:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.DataInputStream;
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.io.StreamConnection;
    import javax.microedition.media.Manager;
    import javax.microedition.media.Player;
    import javax.microedition.midlet.*;

    /**
    * @author pavan
    */
    public class Httpconnection extends MIDlet {

    public void startApp() {
    new Thread()
    {
    public void start(){
    System.out.println("Player started");
    String url = "http://teluguone.com/tmdb/videos/Chinna-Becomes-Fool--Superb-Comedy-With-His-Son-9536.html";
    // Open connection to the http url...
    DataInputStream dataIn = null;
    HttpConnection connection = null;
    try {
    connection = (HttpConnection) Connector.open(url);
    dataIn = connection.openDataInputStream();
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    byte[] buffer = new byte[1024];
    int read = -1;

    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    try {
    while ((read = dataIn.read(buffer)) >= 0) {
    byteout.write(buffer, 0, read);
    }
    dataIn.close();

    connection.close();

    } catch (IOException ex) {
    ex.printStackTrace();
    }
    ByteArrayInputStream byteIn =
    new ByteArrayInputStream(byteout.toByteArray());

    try {
    Player p = Manager.createPlayer(byteIn, "video/mp4");

    p.realize();
    p.prefetch();
    p.start();
    System.out.println("Player started");
    } catch (Exception e) {
    System.out.println("Exception :" + e);
    }
    }
    }.start();

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
    }

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

    Re: Streaming youtube videos on j2me MIDlet(java)

    The url you provided has youtube video embedded. As said in the above mentioned thread, platformRequest() is the only way I can think to launch the browser and play video. But youtube video plays only on the brower which has Flash or HTML5 player support. As far as I know, S40 browser doesn’t support flash or html5 player.

    Symbian devices supports flash player.

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

    Re: Streaming youtube videos on j2me MIDlet(java)

    You can actually find an rtsp streaming URL address from a youtube video, if you go to the mobile version of youtube from your Desktop browser:

    m.youtube.com

    search and find the video you need to stream, then right click on the thumbnail picture of the video and select "Copy Link Location" on Firefox.

    As soon as you have the rtsp address, you should be able to play the video (at least it works on Nokia Belle) by using this snippet:
    http://www.developer.nokia.com/Resou...ing-video.html
    provided that you use this argument:
    createPlayer("rtps://linkhere");

    and DIRECT_VIDEO as display mode. I have now created a new wiki article here:
    http://www.developer.nokia.com/Commu...r_with_Java_ME
    Last edited by skalogir; 2012-08-10 at 13:25. Reason: New wiki article created

Similar Threads

  1. Shoutcasting Internet Radio Streaming and playing Mp3 Files in J2me Midlet(Java):
    By pavanragi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2012-08-20, 07:35
  2. Streaming youtube videos on j2me MIDlet(java)
    By pavanragi in forum General Development Questions
    Replies: 2
    Last Post: 2012-08-12, 22:06
  3. Live video streaming on youtube in J2ME
    By omnia amr in forum Mobile Java General
    Replies: 1
    Last Post: 2012-02-07, 07:33
  4. Playing Youtube videos in Java Apps
    By scharffc in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2010-06-06, 09:46

Posting Permissions

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