Results 1 to 3 of 3

Thread: Help with JMF?!

  1. #1
    JavaNoob!1 is offline Member
    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0

    Default Help with JMF?!

    I have tried so many things, and I think the problem is that I'm on a mac, because I have copy pasted so much code just to try to start this program. Here is the program (to run it you have to have the JMF API) JMF 2.1.1e Software

    Here's the class that generates the player

    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.io.IOException;
    import java.net.URL;
    import javax.media.CannotRealizeException;
    import javax.media.Manager;
    import javax.media.NoPlayerException;
    import javax.media.Player;
    import javax.swing.JFrame;

    public class MediaPanel extends JFrame
    {
    private final static long serialVersionUID = 15L;

    private Player player;

    public MediaPanel(String title, URL url)
    {
    super(title);
    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
    try{
    createPlayerAndShowComponents(url);

    }
    catch(CannotRealizeException e){
    System.err.println("YOU SUCK");
    }
    catch(NoPlayerException e){
    System.err.println("YOU SUCK!");
    }
    catch(IOException e){
    System.err.println("YOU SUCK!!");
    }
    }

    private void createPlayerAndShowComponents(URL url) throws
    IOException, CannotRealizeException, NoPlayerException
    {
    player = Manager.createRealizedPlayer(url);
    Component comp;
    if((comp = player.getVisualComponent()) != null){
    add(comp, BorderLayout.CENTER);
    }
    if((comp = player.getControlPanelComponent()) != null){
    add(comp, BorderLayout.SOUTH);
    }

    }

    // end class MediaPanel

    }


    And here's the class that tests if it actually works:

    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.swing.JFrame;
    import javax.swing.JFileChooser;


    public class MediaTest
    {
    @SuppressWarnings("deprecation")
    public static void main( String args[] )
    {
    // create a file chooser
    JFileChooser chooser = new JFileChooser();

    // show open file dialog
    int result = chooser.showOpenDialog( null );

    if ( result == JFileChooser.APPROVE_OPTION ) // user chose a file
    {
    try{
    URL url = chooser.getSelectedFile().toURL();

    createAndShowGUI(url);
    }
    catch(MalformedURLException ex){
    System.err.println("Soozzzzzz");
    }

    }
    }

    public static void createAndShowGUI(URL url){
    MediaPanel panel = new MediaPanel("Simple Player", url);
    panel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    panel.setSize(400, 300);
    panel.setVisible(true);


    }

    }





    I keep getting the error where it catches the NoPlayerException... Help please!

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: Help with JMF?!

    Please use [code] tags [/code] when posting code, as that is unreadble without them.
    Also post the full error text and the line it occurs on.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Help with JMF?!

    Quote Originally Posted by JavaNoob!1 View Post
    I have tried so many things, and I think the problem is that I'm on a mac, because I have copy pasted so much code just to try to start this program. Here is the program (to run it you have to have the JMF API) JMF 2.1.1e Software
    If you're using Eclipse then I think this is salvation for your problem:

    [Eclipse] Access restriction: Class is not accessible due to restriction on required library @Digizol

    This part of that topic is most important:

    Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
    (Project) Properties -> Java Compiler -> Errors/Warnings
    Last edited by cselic; 07-17-2012 at 12:23 AM. Reason: typos

Tags for this Thread

Posting Permissions

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