Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to play a video using JMF. Also I am using netbeans in Ubuntu. Not getting any error in the program. but I cant open video. Instead am getting a dialog box having error message as "No media Player found".

Actually I have written program like when I click button5, the video file has to play by selecting file using JFilechooser.
Here is my code

Java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
    try {
            openMedia();
        } catch (IOException ex) {
            //Logger.getLogger(SoundBytePlaying.class.getName()).log(Level.SEVERE, null, ex);
        }
}


public void openMedia() throws IOException{
        JFileChooser fileChooser = new JFileChooser();
        int result = fileChooser.showOpenDialog(jButton5);
        if(result == JFileChooser.APPROVE_OPTION)
        {
            URL mediaURL = null;
            try{
                mediaURL = fileChooser.getSelectedFile().toURL();
            }catch(MalformedURLException malformedURLException){
                JOptionPane.showMessageDialog(null, "Could not create URL for the file");
            }
            if(mediaURL != null){
                showVideo(mediaURL); //some error here**
                System.out.println("camera displaying..");
            }
        }
    }    


 public void showVideo(URL mediaURL){
        Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );

        try{
            //create a player to play the media specified in the URL
            Player mediaPlayer = Manager.createRealizedPlayer( mediaURL );

            //get the components for the video and the playback controls
            Component video = mediaPlayer.getVisualComponent();
            Component controls = mediaPlayer.getControlPanelComponent();

            if ( video != null )
                add( video, BorderLayout.CENTER ); //add video component
            if ( controls != null )
                add( controls, BorderLayout.SOUTH ); //add controls

                mediaPlayer.start(); //start playing the media clip
        } //end try
        catch ( NoPlayerException noPlayerException ){
            JOptionPane.showMessageDialog(null, "No media player found");
        } //end catch
        catch (CannotRealizeException ex){
            JOptionPane.showMessageDialog(null, "Could not realize media player.");
        } //end catch
        catch (IOException iOException ){
            JOptionPane.showMessageDialog(null, "Error reading from the source.");
        } //end catch
    }

Please Guide me.
Thank you.
Posted
Updated 9-Sep-14 7:37am
v2

1 solution

Please do not repost, this is an exact duplicate of How do I link video using jmf.jar[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900