play video with JMF and LINUX

Discussion in 'Java' started by Andrea Beccari, Mar 5, 2004.

  1. I'm writing a program for playing an avi file (cinepak codec) using the Java
    Media Framework.
    No problem if I run it under Windows, but when I try to play it under Linux
    (fedora) I can only hear the sound of the video and I see nothing.

    Please help...

    This is the simple code that I have written:

    package Client;

    import javax.media.*;
    import javax.media.format.*;
    import javax.media.protocol.*;

    import javax.sound.sampled.*;
    import javax.sound.sampled.spi.*;


    import java.util.logging.*;

    import java.awt.image.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.URL;
    import java.util.*;

    public class RouletteGUI extends javax.swing.JFrame implements
    ControllerListener{
    String videoFile="/home/game/media/roulette/video_0.avi";
    MediaLocator src;
    Player video;
    //JPanel videoP=new JPanel(true);

    /** Creates new form RouletteGUI */
    public RouletteGUI() {
    initComponents();


    //JOptionPane.showMessageDialog(null,"file:"+videoFile+"_"+i+"."+videoExt);
    src = new MediaLocator("file:"+videoFile); //setto l'URL
    System.out.println("MediaLocator file:"+videoFile);


    System.out.println("createPlayer file:"+videoFile);
    try {
    video = Manager.createPlayer(src);
    }catch (Exception e) {
    JOptionPane.showMessageDialog(null,"err :"+e);
    }
    video.addControllerListener(this);
    // video.realize();
    System.out.println("realized");
    }

    /** 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() {
    videoP = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();

    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    }
    });

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

    videoP.add(jButton1);

    getContentPane().add(videoP, java.awt.BorderLayout.CENTER);

    pack();
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // Add your handling code here:
    video.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 RouletteGUI().show();
    }

    public void controllerUpdate(javax.media.ControllerEvent evt) {

    //videoF.getContentPane().add(video[numeroEstratto].getVisualComponent(),
    BorderLayout.CENTER);
    if(evt instanceof RealizeCompleteEvent)
    {
    videoP.setLayout(new BorderLayout());
    videoP.add(video.getVisualComponent());
    }
    else if (evt instanceof StartEvent) {
    videoP.show();
    }
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel videoP;
    // End of variables declaration

    }
     
    Andrea Beccari, Mar 5, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tochaotic4u
    Replies:
    2
    Views:
    4,063
    tochaotic4u
    Jul 3, 2003
  2. Josef Garvi

    JMF - can it play dv avi files?

    Josef Garvi, Apr 20, 2004, in forum: Java
    Replies:
    4
    Views:
    6,427
    ramkumarm
    Apr 15, 2009
  3. Will
    Replies:
    0
    Views:
    1,915
  4. Replies:
    1
    Views:
    757
    Andrew Thompson
    Jul 20, 2006
  5. Replies:
    0
    Views:
    2,350
Loading...

Share This Page