×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Could Not Create Player

    Hi,

    I am trying to build a sound recording application on Series 60 2nd Edition platform using J2ME.

    Following is a snippet of my code for the same:

    //Imports Section
    import java.io.IOException;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.Control.*;
    import com.nokia.microedition.media.control.RecordControl;


    //Method to start recording
    public void StartRecording()
    {
    try
    {
    //Create a player
    Player p = Manager.createPlayer("capture://audio");
    p.realize();
    //Get RecordControl, Set RecordLocation and Record for 5 secs
    RecordControl rc=(RecordControl)p.getControl("RecordControl");
    rc.setRecordLocation("file:/tmp/audio.wav");
    rc.startRecord();
    p.start();
    Thread.currentThread().sleep(5000);
    p.stop();
    rc.stopRecord();
    rc.commit();


    }
    catch(Exception ex)
    {
    Form frm3=new Form("Record Error");
    frm3.append(ex.getMessage());
    Display.getDisplay(this).setCurrent(frm3);
    }
    }


    I have referred the example given in the forum, but when i run it in the emulator it gives me the "Could not create Player" error.

    I am pretty new to development on this platform. Can someone please guide me here.

    Thanks,
    Saket

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Posts
    159

    Re: Could Not Create Player

    please check this link i think this is usefull to you
    http://www.java2s.com/Tutorial/Java/...turedAudio.htm

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: Could Not Create Player

    Thanks sis1987.

    I went through the example provided in the link and it seems that syntactically both the codes are similar. Especially the line to create the player:

    Link Example:
    capturePlayer = Manager.createPlayer("capture://audio");

    My Code:
    Player p;
    p = Manager.createPlayer("capture://audio");

    Yet i get the error ("Could not Create Player") above.

    As of now it does not appear to be a issue with the code. I guess i am missing something else.

    Also one more point. I get the createPlayer in italics. Could that mean anything?

    Regards,
    Saket

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: Could Not Create Player

    One more observation......

    If i change the value in the media locator then i do not get any issues.

    For eg:

    if i change the existing line:

    Player p=Manager.createPlayer("capture://audio");

    to this:

    Player p=Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);

    or this:

    InputStream is=getClass().getResourceAsStream("audio.wav");
    Player p=Manager.createPlayer(is,"audio/X-wav");

    Then the error disappears. I am now wondering if this has something to do with the
    "capture://audio" statement.....

    Any Ideas?

    Regards,
    Saket

  5. #5
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Could Not Create Player

    on which phone are you trying this ?
    Or are you trying on an emulator ?
    It might be so that the emulator doesn't support it, for example some emaultors (like wtk) are very limited themselves with what a Player actually can do (record but also play)...

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: Could Not Create Player

    Hi Tiger79


    on which phone are you trying this ?
    I am trying this on Nokia 3500c handset.
    Or are you trying on an emulator ?
    I am not trying it on a emulator since emulator does not support audio capture

    Surprisingly, i simply included the encoding part in the CreatePlayer locator and it started working. But it should work without the encoding too right?

    Even more surprising later when i removed the encoding the app works......

    Right now i am not going too deep into why this happened due to time constraints. But i guess since i am new i may have gone wrong somewhere....

    However, if somebody can throw some light on this then i will greatly appreciate.

    Thanks,
    Saket

  7. #7
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Could Not Create Player

    you could start by trying out :

    player=Manager.createPlayer(“capture://audio?encoding=amr”);
    player.realize();

    Have a look at this tutorial, it's pretty good, even if a little old :
    http://www.hcilab.org/documents/tutorials/AudioTest/

  8. #8
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: Could Not Create Player

    Thanks Tiger79!

    I am pretty sure that the link should be very helpful for me.....

  9. #9
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: Could Not Create Player

    Okay just an update.

    In my case i figured out that the issue could be related to the location where the file is getting created/saved on the device. Maybe it has something to do with the size constraints. Because initially when i was saving the file to the default phone memory i was getting such issues. However, once i changed the path to my external memory the error has stopped occurring.

    I am not sure if this is the actual reason but it worked for me.

    Regards,
    Saket

Similar Threads

  1. application error with 3gp file in J2ME
    By ruchig_iic in forum Mobile Java Media (Graphics & Sounds)
    Replies: 10
    Last Post: 2012-01-16, 21:40
  2. Replies: 48
    Last Post: 2009-09-18, 15:56
  3. VideoStreaming player realize takes too long
    By cristi.mota in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-10-03, 10:29
  4. cannot able to play a video file.
    By shalini.mishra in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2006-11-13, 16:54
  5. Chaining Player instances smoothly
    By jrosebor in forum Mobile Java General
    Replies: 3
    Last Post: 2005-10-18, 06:36

Posting Permissions

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