×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2008
    Location
    Kazakhstan, Almaty
    Posts
    17

    Lightbulb playTone and wav player doesnt work. (nokia 5320)

    1. I dont know why, but playTone doestn work. I'm looking on specs (UAProfile) and I can see that this device understands x-tone-seq. (Device specifications : 5320 XpressMusic)

    2. Trying to learn more about sounds in j2me and when app tryes to play sound, I see this error: java.lang.NullPointerException: 0


    Code:
    /*
    * soundtest.java
    */
    package soundtest;
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    //import java.lang.*;
    import java.io.*;
    
    public class soundtest extends MIDlet implements CommandListener {
    
        private Command exitCmd  = new Command("Exit", Command.EXIT, 1);
    	private Command beepCmd  = new Command("Beep", Command.ITEM, 1);
    	private Command soundCmd  = new Command("Sound", Command.ITEM, 2);		
    	private InputStream is;
    	private Player player;
        private Display display;
        private Form mainForm;	
    
        public soundtest(){
        }
        
        protected void destroyApp(boolean unconditional){
        }
        
        protected void pauseApp(){
        }
        
        protected void startApp()throws MIDletStateChangeException{
            display = Display.getDisplay(this);	
    		try {
    		
    		// ===================================================== I use standart WTK20 so path for file should be like this? 
    		InputStream is = getClass().getResourceAsStream("/audio.wav");
                               
    		Player player = Manager.createPlayer(is, "audio/x-wav");	
    		
    		} catch (Exception e){
    						System.out.println("Error in def section: "+
                                e.toString());
    		}
            mainForm = new Form("soundtest");		
            mainForm.addCommand(exitCmd);
            mainForm.addCommand(beepCmd);
            mainForm.addCommand(soundCmd);		
            mainForm.setCommandListener(this);		
            display.setCurrent(mainForm);
        }
        
        public void commandAction(Command c, Displayable d) {
            if (c == exitCmd) {
                destroyApp(false);
                notifyDestroyed();        
            }    
            if (c == beepCmd) {
    			try {
    				Manager.playTone(ToneControl.C4, 250, 100);
    				} catch (MediaException e) {
    					//
    					System.out.println("Unable to execute ");
    			}
    		}
    		if (c == soundCmd) {
    			try {
    				player.prefetch();
    				player.start();
    				}
    				catch(Exception e) {
    				System.out.println("Error in play section: "+
                                e.toString());
    				}
            }
        }

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: playTone and wav player doesnt work. (nokia 5320)

    I suspect that the file you are trying to load is there in resource folder of the project...
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Dec 2008
    Location
    Kazakhstan, Almaty
    Posts
    17

    Re: playTone and wav player doesnt work. (nokia 5320)

    problem was with device. I made reset to defaults and now all works well.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Re: playTone and wav player doesnt work. (nokia 5320)

    i think just u check ur mobile phone ring tones if its working then there is no sound for gaming means ur media file only corrupted so u go to Nokia care center

Similar Threads

  1. Nokia 6220c Camera doesnt work
    By tearcodiac in forum General Development Questions
    Replies: 2
    Last Post: 2009-12-28, 17:16
  2. E71: refresh music player list doesnt work
    By Mike-Danz in forum Audio
    Replies: 4
    Last Post: 2009-01-20, 09:32
  3. KEY_SOFTKEY3 Nokia 6131 doesnt work
    By ivanmilara in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-08-21, 12:17
  4. getRGB doesnt work on my Nokia Series 60 Emulator
    By rj_cybersilver in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2005-09-19, 03: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
  •