play video with JMF and LINUX

A

Andrea Beccari

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

}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top