×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    51

    application error with 3gp file in J2ME

    Hi all ,

    i had created one video player which is used to play 3gp file, MPEG file and an audio file using MMAPI and J2ME application.
    i used J2ME wireless toolkit for this video player its working in J2ME wireless tool kit but when i install that application using .jad and .jar file its not working on a real device(sony ericsson K750i). it shows an application error in that.. what should i do.
    i am sending u my src file midlet please tell me where is the problem.


    import java.util.Hashtable;
    import java.util.Enumeration;

    import javax.microedition.lcdui.Item;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.CommandListener;

    import javax.microedition.media.Player;
    import javax.microedition.media.Control;
    import javax.microedition.media.Manager;
    import javax.microedition.media.PlayerListener;
    import javax.microedition.media.control.VideoControl;

    public class MediaMIDlet extends MIDlet
    implements CommandListener, PlayerListener {

    private Display display;
    private List itemList;
    private Form form;

    private Command stopCommand;
    private Command pauseCommand;
    private Command startCommand;

    private Hashtable items;
    private Hashtable itemsInfo;

    private Player player;

    public MediaMIDlet() {

    display = Display.getDisplay(this);

    // creates an item list to let you select multimedia files to play
    itemList = new List("Select an item to play", List.IMPLICIT);

    // stop, pause and restart commands
    stopCommand = new Command("Stop", Command.STOP, 1);
    pauseCommand = new Command("Pause", Command.ITEM, 1);
    startCommand = new Command("Start", Command.ITEM, 1);

    // a form to display when items are being played
    form = new Form("Playing media");

    // the form acts as the interface to stop and pause the media
    form.addCommand(stopCommand);
    form.addCommand(pauseCommand);
    form.setCommandListener(this);

    // create a hashtable of items
    items = new Hashtable();

    // and a hashtable to hold information about them
    itemsInfo = new Hashtable();

    // and populate both of them


    items.put("Siren from jar", "file://siren.wav");
    itemsInfo.put("Siren from jar", "audio/x-wav");

    items.put("Promo Video from jar", "file://promo.mpg");
    itemsInfo.put("Promo Video from jar", "video/mpeg");

    items.put("Video 3GP from jar", "file://l23.3gp");
    itemsInfo.put("Video 3GP from jar", "video/3gpp");

    }

    public void startApp() {

    // when MIDlet is started, use the item list to display elements
    for(Enumeration en = items.keys(); en.hasMoreElements() {
    itemList.append((String)en.nextElement(), null);
    }

    itemList.setCommandListener(this);

    // show the list when MIDlet is started
    display.setCurrent(itemList);
    }

    public void pauseApp() {
    // pause the player
    try {
    if(player != null) player.stop();
    } catch(Exception e) {}
    }

    public void destroyApp(boolean unconditional) {
    if(player != null) player.close(); // close the player
    }

    public void commandAction(Command command, Displayable disp) {

    // generic command handler

    // if list is displayed, the user wants to play the item
    if(disp instanceof List) {
    List list = ((List)disp);

    String key = list.getString(list.getSelectedIndex());

    // try and play the selected file
    try {
    playMedia((String)items.get(key), key);
    } catch (Exception e) {
    System.err.println("Unable to play: " + e);
    e.printStackTrace();
    }
    } else if(disp instanceof Form) {

    // if showing form, means the media is being played
    // and the user is trying to stop or pause the player
    try {

    if(command == stopCommand) { // if stopping the media play

    player.close(); // close the player
    display.setCurrent(itemList); // redisplay the list of media
    form.removeCommand(startCommand); // remove the start command
    form.addCommand(pauseCommand); // add the pause command

    } else if(command == pauseCommand) { // if pausing

    player.stop(); // pauses the media, note that it is called stop
    form.removeCommand(pauseCommand); // remove the pause command
    form.addCommand(startCommand); // add the start (restart) command
    } else if(command == startCommand) { // if restarting

    player.start(); // starts from where the last pause was called
    form.removeCommand(startCommand);
    form.addCommand(pauseCommand);
    }
    } catch(Exception e) {
    System.err.println(e);
    }
    }

    }

    /* Creates Player and plays media for the first time */
    private void playMedia(String locator, String key) throws Exception {

    // locate the actual file, we are only dealing
    // with file based media here
    String file = locator.substring(
    locator.indexOf("file://") + 6,
    locator.length());

    // create the player
    // loading it as a resource and using information about it
    // from the itemsInfo hashtable
    player =
    Manager.createPlayer(
    getClass().getResourceAsStream(file), (String)itemsInfo.get(key));

    // a listener to handle player events like starting, closing etc
    player.addPlayerListener(this);

    player.setLoopCount(-1); // play indefinitely
    player.prefetch(); // prefetch
    player.realize(); // realize

    player.start(); // and start

    }

    /* Handle player events */
    public void playerUpdate(Player player, String event, Object eventData) {

    // if the event is that the player has started, show the form
    // but only if the event data indicates that the event relates to newly
    // stated player, as the STARTED event is fired even if a player is
    // restarted. Note that eventData indicates the time at which the start
    // event is fired.
    if(event.equals(PlayerListener.STARTED) &&
    new Long(0L).equals((Long)eventData)) {

    // see if we can show a video control, depending on whether the media
    // is a video or not
    VideoControl vc = null;
    if((vc = (VideoControl)player.getControl("VideoControl")) != null) {
    Item videoDisp =
    (Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null);
    form.append(videoDisp);
    }

    display.setCurrent(form);
    } else if(event.equals(PlayerListener.CLOSED)) {

    form.deleteAll(); // clears the form of any previous controls
    }
    }

    }
    Regards
    Ruchi
    ruchi.gupta@bhartitelesoft.com

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: application error with 3gp file in J2ME

    hi,

    fyi: here is SE example article (+files) about MMAPI (135) playback from resource files:
    http://developer.sonyericsson.com/si...diomidp2.0.jsp

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: application error with 3gp file in J2ME

    Hi,

    can some body send me the application which helps in playing the 3gp video file in J2ME.


    here is the code below:

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;

    import java.io.*;

    import javax.microedition.io.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;

    public class MIDlet1 extends MIDlet {
    private static MIDlet1 instance;


    /** Constructor */
    public MIDlet1() {
    instance = this;
    }

    /** Main method */
    public void startApp() {

    System.out.println("Hello World 2 from Middlet startApp()");
    InputStream dis =null;

    try {

    HttpConnection c = (HttpConnection)Connector.open("http://localhost:8080/VideoStreaming/San.3gpp", Connector.READ);


    System.out.println("after");

    dis = c.openInputStream();

    System.out.println(dis.available());
    }
    catch(Exception e) {
    e.printStackTrace();
    }

    Canvas canvas = new Canvas() {
    public void paint(Graphics g) {
    g.setColor(255, 0, 0);
    g.fillRect(0, 0, getWidth(), getHeight( ));
    g.setColor(255, 255, 255);
    g.drawString("Hello World!", 0, 0, g.TOP | g.LEFT);
    }
    };

    Display display = Display.getDisplay(this);
    display.setCurrent(canvas);

    if ( dis != null) {

    System.out.println("Trying to access player...");

    try {
    Player p = Manager.createPlayer(dis, "video/3gpp");
    // Player p = Manager.createPlayer(dis, "video/mpeg");

    p.realize();
    VideoControl vc;
    if ( (vc = (VideoControl) p.getControl("VideoControl")) != null) {
    vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, canvas);
    vc.setDisplayLocation(0,0);
    vc.setDisplaySize(100,100);
    vc.setVisible(true);
    }
    p.start();
    System.out.println("duration: " + p.getDuration());
    }
    catch (MediaException pe) {
    pe.printStackTrace();
    }
    catch (IOException ioe) {
    ioe.printStackTrace();
    }
    }

    }

    /** Handle pausing the MIDlet */
    public void pauseApp() {
    }

    /** Handle destroying the MIDlet */
    public void destroyApp(boolean unconditional) {
    }

    /** Quit the MIDlet */
    public static void quitApp() {
    instance.destroyApp(true);
    instance.notifyDestroyed();
    instance = null;
    }


    }


    ERROR: getting the following error

    javax.microedition.media.MediaException: Cannot create a Player for: video/3gpp

    trie da lot to solve but couldn't.

    please help me.

    not able to run the video file in emulator neither in phone(Nokia 6681)

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: application error with 3gp file in J2ME

    ERROR: getting the following error

    javax.microedition.media.MediaException: Cannot create a Player for: video/3gpp
    Try a newer emulator, or a Prototype SDK. What this message tells you is that the emulator you're using does not support playing 3gp videos from Java. Also, you need to make sure you have a web server running where the video is hosted...

    Daniel

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    5

    Re: application error with 3gp file in J2ME

    Hi manaspaira

    I got the same error which you got.....

    if you got any solution for this issue kindly mail me on adesh.arote@gmail.com

    Regards
    Adesh

  6. #6
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: application error with 3gp file in J2ME

    Hello Adesh,

    and welcome to Nokia Developer Discussion Boards!

    Please note that this discussion thread is some 4 years old, so it could be that some of the original participants are not actively following this discussion anymore.

    Could you provide more information on the issue which you are facing currently?

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    5

    Re: application error with 3gp file in J2ME

    Hello r2j7,

    Thank you...

    Actually i have to create a java application which will play a 3gp file. I used this source code to create an application and i had successfully created that application, but the problem is when i run this application in nokia mobile it works properly and other mobile like sony eriscon its not working properly...


    If you have any solution please provide me..

    Regards,
    Adesh

  8. #8
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: application error with 3gp file in J2ME

    Hello Adesh,

    since the issue is about a non-Nokia device, it could be that the playback of such file is not supported. However in order to be sure on this topic and especially regarding the Sony Ericsson device, you might want to check the status by using Sony Ericsson developer resources here: http://developer.sonyericsson.com/wp...es?cc=gb&lc=en

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  9. #9
    Registered User
    Join Date
    Dec 2011
    Posts
    5

    Re: application error with 3gp file in J2ME

    Hello r2j7

    Thank you for your co-operation


    Regards,
    Adesh

  10. #10
    Registered User
    Join Date
    Dec 2011
    Posts
    5

    Re: application error with 3gp file in J2ME

    Hello r2j7

    I have one more query can we find memory card serial no which is available in mobile?

    Regards
    Adesh

  11. #11
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: application error with 3gp file in J2ME

    Hello Adesh,

    unfortunately that cannot be achieved by using the standard Java ME or the Java APIs by Nokia.

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

Similar Threads

  1. How can the WAP browser communicate to J2ME application?
    By hbfornies in forum Mobile Java General
    Replies: 20
    Last Post: 2007-03-02, 16:32
  2. Replies: 9
    Last Post: 2006-05-11, 21:13
  3. Start a J2ME application by OTA
    By hbfornies in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-09-24, 17:14
  4. Start a J2ME application by OTA
    By hbfornies in forum Mobile Java General
    Replies: 1
    Last Post: 2003-09-23, 10:01
  5. merging 2 sis file of same application
    By amardeep in forum Symbian
    Replies: 2
    Last Post: 2003-04-25, 07:48

Posting Permissions

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