Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

JMF application

  • 03-03-2006 01: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, Registered Users 2 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