Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JMF application

Options
  • 03-03-2006 1:05pm
    #1
    Closed Accounts Posts: 27


    does anybody know much about the JMF?

    Im developing an mp3 player application in java. Basically it has a stop and a start button and at the moment it plays an mp3 file thats in that directory. But the stop button doesnt work!! Its been driving me mad. Here is the piece of code concerning:

    public void actionPerformed( ActionEvent e )
    {
    if ( e.getSource() == btPlay_Button )
    {
    try
    {
    String url= "file:RedDawn.mp3";
    MediaLocator mediaLocator= new MediaLocator(url);
    Player mp3Player = Manager.createPlayer(mediaLocator);
    mp3Player.start();
    }
    catch (Throwable t)
    {
    t.printStackTrace();
    }
    }
    if ( e.getSource() == btStop_Button )
    {
    mp3Player.stop();
    mp3Player.deallocate();
    }
    }


Comments

  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    Can't really see anything that jumps out at me, although I'd be a little worried aboutyour tests for the UI objects. What I mean is that I'd explicity cast the event source to a button, something like:
    Button button = (Button) e.getSource();
    if (button == btPlay_Button) {
       blah, blah, blah;
    } else if (button == btStop_Button) {
       blah, blah, blah;
    }
    


Advertisement