Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to play videos using netbeans 7.0.1.
For that I have added jmf.jar in library. But I am getting an error like
"No media Player is found".
I am using JMF in netbeans7.0.1.
Here is my code

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
}
Posted
Updated 8-Sep-14 23:45pm
v3
Comments
Richard MacCutchan 9-Sep-14 3:12am    
netbeans is an IDE so it won't play videos.

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