×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    43

    problem with playing Wav in 7210

    below is my code:
    when i run it, exception occurs & prints "bading".
    can someone solve it?
    thanks

    //**************************************
    package slidergame;

    import javax.microedition.lcdui.*;
    import java.util.Timer;
    import java.util.TimerTask;
    import com.nokia.mid.ui.*;
    import com.nokia.mid.sound.Sound;
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;



    public class SplashFullCanvas extends FullCanvas {
    private GameMIDlet parent = null;
    private MainMenu menu = null;
    private Timer timer = null;
    private Image splash = null;
    public InputStream tune;
    public byte buffer[];
    public Sound sound;


    public SplashFullCanvas(GameMIDlet parent) {
    this.parent = parent;
    menu = new MainMenu(Resources.getString(Resources.ID_GAME_NAME),List.IMPLICIT, parent);
    try{
    //InputStream tune;
    //byte buffer[];
    //Sound sound;
    tune = this.getClass().getResourceAsStream("/BWANG.WAV");
    buffer = new byte[4460]; // 4460 is the file size
    tune.read(buffer, 0, buffer.length);
    sound = new Sound(buffer, Sound.FORMAT_WAV);
    sound.init(buffer, Sound.FORMAT_WAV);
    sound.play(1);
    }
    catch(Exception e){
    System.out.println("bading");
    }

    try
    {
    splash = Image.createImage("/splash.PNG");
    }
    catch (java.io.IOException e)
    {
    System.err.println("Unable to locate splash screen");
    }
    startTimer();

    }

    protected void paint(Graphics g) {
    //g.setColor(0,0,255);
    //g.fillRect(0,0, getWidth(), getHeight());
    if(splash!=null){
    g.drawImage(splash, 0, 0, Graphics.LEFT | Graphics.TOP);
    }

    }




    protected void keyPressed(int keyCode){
    timer.cancel();
    timer = null;
    parent.setDisplayable(menu);
    splash = null;
    }

    private void startTimer(){
    TimerTask task =
    new TimerTask() {
    public void run() {
    parent.setDisplayable(menu);
    splash = null;
    }
    };
    timer = new Timer();
    timer.schedule(task, 5000);
    }
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Are you sure the phone supports WAV format?
    Try printing the exception in the catch block to get a more detailed error message:
    Code:
    catch (Exception e) {
        e.printStackTrace(); // or System.out.println(e);
    }

Posting Permissions

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