Bom Galera, estou com o livro da DEITEL do lado e so copiei o codigo do player de video igualzinho o do livro, mas entao porque ta dando erro ?
O codigo é executado em 2 classes vou passar as 2, por download, mas se prefirirem o codigo eu tbm ponho, a primeira da erro a segunda não !
Classe 1
package mediaPlayer;
import java.awt.BorderLayout;
import java.awt.Color;
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.JPanel;
public class MediaPanel extends JPanel {
public MediaPanel (URL media URL){
setLayout (new BorderLayout());
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
try{
Player mediaPlayer = Manager.createRealizedPlayer(media URL);
Component video = mediaPlayer.getVisualComponent();
Component controls = mediaPlayer.getControlPanelComponent();
if( video != null)
add(video, BorderLayout.CENTER);
if(controls != null)
add( controls, BorderLayout.SOUTH)
mediaPlayer.start();
}
catch (NoPlayerExcepition noPlayerException){
System.err.println("No media player found");
}
catch (CannotRealizeException cannotRealizeException){
System.err.println("Could not realize media player");
}
catch(IOException iOExcepition){
System.err.println("error reading from the source");
}//fimdocatch
} //fim do contrutor MediaPlayer
}//fim da classe
Classe 2
package mediaPlayer;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
public class MediaTest {
public static void main (String [] args){
JFileChooser fileChooser = new JFileChooser();
int result = fileChooser.showOpenDialog(null);
if ( result == JFileChooser.APPROVE_OPTION){
URL mediaURL = null;
try{
mediaURL = fileChooser.getSelectedFile().toURI().toURL();
}
catch(MalformedURLException malformedURLException){
System.err.println("coul not creat URL from the file");
}//fimdocartch
if (mediaURL != null){
JFrame mediaTest = new JFrame();
mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MediaPanel mediaPanel = new MediaPanel(mediaURL);
mediaTest.add(mediaPanel);
mediaTest.setSize(300,300);
mediaTest.setVisible(true);
}//fim do if externo
}//fim do if externo
}//fimdemain
}//fimdaclassemediatest