×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    5

    Question help with playing audio!! desperate!

    hello everyone..

    i am in desperate need of help. i am developing a greeting card application
    and i want the card to consist of an image, audio and video. So far, my application displays
    an image and what i'm having trouble with is adding the audio. i am attaching my code here
    so i do hope you can help me figure out what the problem is. This code displays an image
    and i added several options to it. I want the audio to play automatically when the image
    is displayed. i am using the nokia 7600 emulator and the Borland JBuilder. i am doing this
    for a university project and i am extremely new to J2ME programming. i do hope you can
    help me with this problem.

    package neatgreets;

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

    public class LCard1
    extends Form
    implements CommandListener {

    Display display;
    private Command backCommand = new Command("Back", Command.BACK, 1);
    private Command sendCommand = new Command("Send", Command.SCREEN, 1);
    private Command addtextCommand = new Command("Add Text", Command.SCREEN, 2);
    private Command addimageCommand = new Command("Add Image", Command.SCREEN, 2);
    private Command addaudioCommand = new Command("Add Audio", Command.SCREEN, 2);
    private Command addvideoCommand = new Command("Add Video", Command.SCREEN, 2);
    private Command saveCommand = new Command("Save", Command.SCREEN, 2);
    private Command okCommand = new Command("OK", Command.OK, 2);
    private Player player;
    private boolean playing = false;
    ImageItem imageItem1;
    private final String midiFile = "\beachboys_kokomo.mid";
    Form form;
    TextBox text;
    TextBox phoneNumber;
    String currentScreen;
    Alert errorMessageAlert;
    Alert sendingMessageAlert;
    Displayable resumeScreen = null;
    static Displayable instance = null;

    public LCard1() {
    super("Card");
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }

    private void jbInit() throws Exception {
    // Set up this Displayable to listen to command events
    imageItem1 = new ImageItem("", null, ImageItem.LAYOUT_CENTER, "");
    imageItem1.setImage(Image.createImage("/neatgreets/ewe.png"));
    setCommandListener(this);
    // add the commands
    addCommand(backCommand);
    addCommand(sendCommand);
    addCommand(addtextCommand);
    addCommand(addimageCommand);
    addCommand(addaudioCommand);
    addCommand(addvideoCommand);
    addCommand(saveCommand);
    this.append(imageItem1);

    InputStream is = getClass().getResourceAsStream("\beachboys_kokomo.mid");
    player = Manager.createPlayer(is, "audio/midi");
    player.start();

    //currentScreen = "Main";

    }

    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();

    if (label.equals("Back")) {
    Display.getDisplay(NeatGreets.instance).setCurrent(Love.instance);

    }

    if (label.equals("OK")) {
    Display.getDisplay(NeatGreets.instance).setCurrent(LCard1.instance);
    }

    if (label.equals("Add Text")) {

    text = new TextBox("Enter Text:", "", 300, TextField.ANY);
    text.addCommand(backCommand);
    text.addCommand(okCommand);
    text.setCommandListener(this);
    display.getDisplay(NeatGreets.instance).setCurrent(text);
    currentScreen = "Text";
    if (label.equals("OK")) {
    Display.getDisplay(NeatGreets.instance).setCurrent(LCard1.instance);
    }
    }
    if (label.equals("Send")) {

    phoneNumber = new TextBox("Enter Phone Number:", "", 24,
    TextField.PHONENUMBER);
    phoneNumber.addCommand(backCommand);
    phoneNumber.addCommand(okCommand);
    phoneNumber.setCommandListener(this);
    display.getDisplay(NeatGreets.instance).setCurrent(phoneNumber);
    currentScreen = "PhoneNumber";
    }

    if (label.equals("OK")) {
    String number = phoneNumber.getString();
    String statusMessage = "Sending message to " + number + "...";
    sendingMessageAlert.setString(statusMessage);
    sendingMessageAlert = new Alert("SMS", null, null, AlertType.INFO);
    sendingMessageAlert.setTimeout(5000);
    sendingMessageAlert.setCommandListener(this);

    }
    }

    private void discardPlayer()
    {
    if (player!=null)
    {
    player.close();
    player = null;
    }
    }

    }


    THIS ARE THE ERROR MESSAGES I RECEIVE:

    C:\JBuilderX\jdk1.4\bin\java -classpath "C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\bin\emulator.jar;C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\bin\jmf.jar" -Demulator.home="C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2" com.nokia.phone.sdk.Emulator -jad "C:\Documents and Settings\KristinChand\jbproject\NeatGreets\NeatGreets.jad"
    Emulator command: C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\bin\midp -heapsize 8M -classpath C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\lib\classes.zip;C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\lib\ext\nokiaui.zip;C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\lib\ext\mma.zip;C:\Nokia\Devices\Nokia_7600_MIDP_Concept_SDK_Beta_0_2\lib\ext\wma.zip;C:\Documents and Settings\KristinChand\jbproject\NeatGreets\NeatGreets.jar -Xdescriptor C:\Documents and Settings\KristinChand\jbproject\NeatGreets\NeatGreets.jad -DcommandPort=3007 -DmirrorPort=3008
    java.lang.IllegalArgumentException
    at javax.microedition.media.Manager.createPlayer(+11)
    at neatgreets.LCard1.jbInit(+116)
    at neatgreets.LCard1.<init>(+146)
    at java.lang.Class.runCustomCode(+0)
    at neatgreets.Love.this_commandPerformed(+43)
    at neatgreets.Love$1.commandAction(+9)
    at javax.microedition.lcdui.ChoiceGroup.uiAction(+82)
    at javax.microedition.lcdui.List.uiAction(+8)
    at javax.microedition.lcdui.CommandSet.consumeKeyEvent(+301)
    at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+43)
    at javax.microedition.lcdui.Display$DisplayManagerImpl.keyEvent(+11)
    at com.nokia.phone.sdk.concept.event.CoreEventHandler.keyEvent(+95)
    at com.nokia.phone.sdk.concept.event.CoreEventHandler$QueuedEventHandler.run(+119)


    THANK YOU SO MUCH FOR YOU TIME!

    CHEERS!
    Kristin

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    87
    I've replied to your identical post in the General section of this forum.

Posting Permissions

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