Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By derata

Thread: J2ME, stop play after pressed button

  1. #1
    derata is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default J2ME, stop play after pressed button

    Hello

    I do alarm clock, but I have problem with stop play after pressing Stop button.

    Thank you for your help

    Java Code:
        public void commandAction(Command c, Displayable s)
        {
            
                                            
          try {
          Player player = Manager.createPlayer(getClass().getResourceAsStream("/ele.wav"), "audio/x-wav");
          player.setLoopCount(3);
          player.prefetch();
    
            if ( c == cmExit)
            {
             
                       
                destroyApp(true);
                notifyDestroyed();
           
            }
    
            if( c == cmActive)
            {   
              player.start();  
    
            }
                if (c == cmCancel)
                {                
              player.stop();  
                }
    
        }
            
             catch (Exception e) {
          e.printStackTrace();
        }  
        }
    Last edited by derata; 04-20-2012 at 12:57 PM.

  2. #2
    derata is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: J2ME, stop play after pressed button

    I know. Please delete.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: J2ME, stop play after pressed button

    This is a forum. Please share the solution.

    Or do you visit a forum only to get and never to give?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    derata is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: J2ME, stop play after pressed button

    I'm sorry

    In Midlet

    Java Code:
        private Player player;
    In startApp()
    Java Code:
     
           try {       
              player = Manager.createPlayer(getClass().getResourceAsStream("/ele.wav"), "audio/x-wav");
              player.setLoopCount(3);
              player.prefetch();
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (MediaException ex) {
                ex.printStackTrace();
            }
    
         }
    And commandAction
    Java Code:
     
        public void commandAction(Command c, Displayable s)
        {
            
                                            
    
    
    
            if ( c == cmExit)
            {
             
                       
                destroyApp(true);
                notifyDestroyed();
           
            }
    
            if( c == cmActive)
            {   
                try {
                    player.start();
                } catch (MediaException ex) {
                    ex.printStackTrace();
                }
    
            }
                if (c == cmCancel)
                {                
                try {
                    player.stop();
                } catch (MediaException ex) {
                    ex.printStackTrace();
                }
                }
    
      
            
    
        }
    DarrylBurke likes this.

Similar Threads

  1. Do events while button is pressed
    By garnaout in forum New To Java
    Replies: 2
    Last Post: 01-24-2012, 09:43 PM
  2. How to set button to be pressed more than once
    By ajs1351 in forum New To Java
    Replies: 20
    Last Post: 12-04-2011, 07:53 AM
  3. Use stop button to stop moving (stop timers) on JPanel
    By mneskovic in forum New To Java
    Replies: 3
    Last Post: 07-23-2010, 01:50 PM
  4. Checking if a button was pressed in a Window.
    By Valkyrie in forum New To Java
    Replies: 2
    Last Post: 12-15-2009, 06:28 AM
  5. Waiting for a button to be pressed
    By SomeGuyOverThere in forum New To Java
    Replies: 6
    Last Post: 08-21-2008, 10:30 PM

Posting Permissions

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