Remove the error of this code plz reply me fast on my mail ID **Deleted by Admin**
package chating;
//import java.applet.Applet; import java.awt.event.*; import java.awt.*; import javax.media.*; import javax.swing.*;
public class Player extends JFrame implements ActionListener, ControllerListener {
JButton fileButton;
JFileChooser file = new JFileChooser();
JLabel urlLabel;
JTextField urlField;
String mediaFile= "";
String FileName = "";
private MediaLocator media;
private javax.media.Player player = null;
private boolean realized = false;
JPanel topPanel, bottomPanel;
Container p = getContentPane();
Component display = null;
public Player() {
super("Media Player v1.0");
setSize(200,150);
//GridLayout myGridLayout = new GridLayout(1,3);
topPanel = new JPanel();
topPanel.setLayout(new FlowLayout());
urlLabel = new JLabel ("File:");
topPanel.add (urlLabel);
urlField = new JTextField (15);
topPanel.add (urlField);
urlField.addActionListener (this);
fileButton = new JButton ("Browse");
topPanel.add (fileButton);
fileButton.addActionListener (this);
p.add(topPanel, BorderLayout.CENTER);
setVisible(true);
}
public void actionPerformed (ActionEvent e) {
if(e.getSource().equals(fileButton))
try
{
file.showOpenDialog(this);
mediaFile = "file:/" ;
mediaFile+=file.getSelectedFile().getAbsolutePath();
FileName = "";
FileName += file.getSelectedFile();
System.out.println(mediaFile);
urlField.setText(mediaFile);
media = new MediaLocator(mediaFile);
player = Manager.createPlayer(media);
player.addControllerListener(this);
wrapRealize();
player.prefetch();
/* addWindowListener( new WindowAdapter() {
public void WindowClosing(WindowEvent we) {
player.stop();
player.deallocate();
player.close();
}
}); */
}
catch (Exception ex){
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Invalid File Format","WARNING !!!",JOptionPane.WARNING_MESSAGE); }
}
public synchronized void wrapRealize() {
player.realize();
while(!realized)
{
try {
wait();
}
catch(InterruptedException interupt)
{
interupt.printStackTrace();
JOptionPane.showMessageDialog(null,"Invalid File Format","WARNING !!!",JOptionPane.WARNING_MESSAGE);
}
}
}
public synchronized void controllerUpdate(ControllerEvent event )
{
if (event instanceof RealizeCompleteEvent){
realized = true;
JFrame playerframe = new JFrame(FileName);
playerframe.setSize(300,200);
playerframe.setLayout(new BorderLayout());
if ((display = player.getVisualComponent()) != null )
{
playerframe.getContentPane().add(display,BorderLayout.CENTER);
}
Component controller = player.getControlPanelComponent();
playerframe.getContentPane().add(controller,BorderLayout.SOUTH);
playerframe.setVisible(true);
notify();
}
else if (event instanceof PrefetchCompleteEvent)
{
player.start();
}
else if( event instanceof EndOfMediaEvent)
{
player.stop();
}
}
public static void main (String args[]) {
Player newPlayer = new Player();
newPlayer.addWindowListener
(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
}