Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Framework java chat using java media
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Atul Jain
java chat using java media
0 Answer(s)      2 years and 8 months ago
Posted in : Framework


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);

                       }
                 }
          );


}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
java chat using java media
java chat using java media   Remove the error of this code plz reply...= ""; String FileName = ""; private MediaLocator media; private... = null; public Player() { super("Media Player v1.0"); setSize
Live Chat Application using java
Live Chat Application using java  I want to develop Live Chat Application for my web site, please help me by posting the code or by giving any suggestion, by which i can develop it.... Thanks in advance
Advertisements
Live Chat Application using java
Live Chat Application using java  I want to develop Live Chat Application for my web site, please help me by posting the code or by giving any suggestion, by which i can develop it.... Thanks in advance
java chat?
java chat?  which is the best tool for java web chat ? Is comet a good techonology ? what about its performance with tomacat 6
java chat application
java chat application  Can u plz send me java code for Lan communicatino(chat
java chat application
java chat application  Can u plz send me java code for Lan communicatino(chat
Chat in Java wih GUI
Chat in Java wih GUI  Welcome all >> << how is everybody >< i wanna Chat program in java server & client thanks
chat application - Java Beginners
chat application  i hv created a chat application , but i hav facing problem when i run it in lan , pc ping but apllication doent giv ressponce plz help for these if some one have work on java chat application my email id
program for chat - Java Beginners
program for chat  please provide code for fallowing 1)Write a java program Multi-user chat server and client
chat server in java - RMI
chat server in java  how develope a chat server in java language,not standalone application,i want to develpoe a web base application,please give me a idea,code, this application deployed in a netwok  Hi Friend
chat server in java - JavaMail
chat server in java  sir i was ask u question related to the chat server,and you has given a answer,but sir i want to make a network based chat server ,in network base chat server ,there is no use of the AWT,SWING,in server side
media player - Java Beginners
media player  Sir I need sourcecode similar to mediaplayer.plz give me somes links to get the source code
Java Media Framework(JMF) - Java Beginners
Java Media Framework(JMF)  Hi everyone I'm designing a media player using jmf,i am not able to stop and old player and start a new one, the code for starting a new player lies in another class whose constructor has been
multi user chat server - Java Beginners
multi user chat server  write a multi chat server and client with step by step explanation? please send me this source code to my mail id with step by step explanation
how to Create a media player - Java Beginners
how to Create a media player  hi great friends my name is David.please i need a source code with detailed explanation on how to create a media player mp3 format.I need this urgently please!my E-mail address
How to make a chat application using Struts 2 ?
How to make a chat application using Struts 2 ?  Hello, I'm working on my final year project. i've to add chat application in that. how it can be done? 'm using eclipse for that.... plzzz reply
chat server - JavaMail
chat server  i want to develop chat server in java using smtp and pop3 protocol.plz tell me what i have to do.what are the APIs i have to use
Chat server
Chat server  Please provide me complete information for making a chat server project using JMS
creating windo chat
creating windo chat   hi ... please could you help me in creating chat aprograme in java ???? with comments beside codes please
Chat Server
are using some core java features like swing, collection, networking, I/O Streams... Chat Server       Chat server is a standlone application that is made up the combination of two
using eval in Java
using eval in Java  using eval in Java
java using Stack - Java Beginners
java using Stack  How convert decimal to binary using stack in java
write a programm using java
write a programm using java  print the following using java programming
Using throw in java method
Using throw in java method  using throw with method implies what
Media Player - Swing AWT
Media Player  Hi All, Could u help me? How can i create new media player in java programming language
chat message
chat message  how to create chat server which should be similar to google talk and facebook etc
survey poll using java
survey poll using java  how to make a survey poll using java? i am using netbeans and glassfish
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
RARP program using java
RARP program using java   hai, how to implement the RARP concept using java
chat server
chat server  i want to develop chat server through jsp+struts+spring+hibernate so please guide me
 

 

 

DMCA.com