JMF so o som o Video que e bom nada

4 respostas
vertuam

Ola All,

Andei dando uma olhada no forum e encontrei alguns codigos de JMF estou testando aqui mas a Imagem nao aparece, saindo apenas o som.

*
 * Player.java
 *
 * Created on 13 de Junho de 2007, 08:54
 */

/**
 *
 * @author  Vertuam
 */

import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URL;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.Time;

import java.lang.String;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.util.Properties;
import javax.media.*;
import com.sun.media.*;

public class Tocador extends javax.swing.JFrame {
    
    Player player = null;
    
    Component vMedia;
    Component controles;
    
    /** Creates new form Player */
    public Tocador() {
        try{
            URL url = new URL("file", null, "c:/renato/downloads/java/jmf/samples/Evanescence.mpg");
            player = Manager.createPlayer(url);
            player.realize();
            
        } catch (Exception e){
            e.printStackTrace();
        }
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        setTitle("Java API JMF Teste");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(null);

        jPanel2.setPreferredSize(new java.awt.Dimension(80, 80));
        jButton1.setText("Play");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel2.add(jButton1);
        jButton1.setBounds(690, 20, 100, 40);

        getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        try{
            vMedia = player.getVisualComponent();
            controles = player.getControlPanelComponent();
            
            if (vMedia != null) {
                jPanel1.add(vMedia, BorderLayout.CENTER);
                jPanel1.revalidate();
                jPanel1.setVisible(true);
            }
            
            if (controles != null) {
                jPanel1.add(controles, BorderLayout.SOUTH);
            }
            
        } catch (Exception e){
            e.printStackTrace();
        }
        player.start();
    }
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new Tocador().show();
    }
          
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration

}

Se alguem puder dar uma ajuda fico grato.

Renato

4 Respostas

vertuam

Consegui resolver o problemas, agora gostaria de saber se para a JMF funcionar corretamente sempre eu devo instalar os seus componetes.

Grato

Renato

R

Gostaria de saber qual foi a solução encontrada, pois estou com o mesmo problema.
Desde já agradeço

L

Qual a solução que você encontrou?
Como conseguiu fazer como que o vídeo funcionasse?

Vlw

R

Gostaria de saber a resolucao…pode colocar o codigo??Estou com o mesmo problema…

Criado 12 de junho de 2007
Ultima resposta 28 de fev. de 2008
Respostas 4
Participantes 4