The Artima Developer Community
Sponsored Link

Java Answers Forum
avi & Swing?? HELP!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Leonardo

Posts: 1
Nickname: zebool
Registered: Oct, 2002

avi & Swing?? HELP!! Posted: Oct 18, 2002 11:24 AM
Reply to this message Reply
Advertisement
I?m working with this code:

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.media.*;
import java.net.*;

public class PlayClip extends JFrame {

//singliton design pattern
private static PlayClip instance;
protected Player player;
private File file= new File ("ICQworking.avi");

private PlayClip () {
instance=null;
initComponents();
}
public static PlayClip getInstance(){

if (instance==null)
instance=new PlayClip ();

return instance;
}

private void initComponents() {
JButton OK = new JButton ("OK");
OK.addActionListener (
new ActionListener () {
public void actionPerformed (ActionEvent e) {
player.close ();
instance = null;
dispose();
}
}
);

getContentPane ().add (OK, BorderLayout.NORTH);

setSize (300, 300);
show ();
createPlayer ();
}

/** Creates new form PlayClip */
private void createPlayer () {
if (file == null) {
return;
}
removePreviousPlayer ();

try {
//create a new player and add listener
player = Manager.createPlayer (file.toURL () );
player.addControllerListener (new EventHandler () );
player.start (); //start player
}
catch (Exception e) {
JOptionPane.showMessageDialog (this, "Invalid file or location", "Error loading file", JOptionPane.ERROR_MESSAGE );
System.exit (1);
}
}

private void removePreviousPlayer () {
if (player == null )
return;

player.close ();

Component visual = player.getVisualComponent ();
Component control = player.getControlPanelComponent ();

Container c = getContentPane ();

if (visual != null)
c.remove (visual);

if (control !=null)
c.remove (control);

}

private class EventHandler implements ControllerListener {
public void controllerUpdate (ControllerEvent e) {
if (e instanceof RealizeCompleteEvent ) {
Container c = getContentPane ();

Component visualComponent = player.getVisualComponent ();

if (visualComponent != null)
c.add (visualComponent, BorderLayout.CENTER);

Component controlsComponent = player.getControlPanelComponent ();

if (controlsComponent != null)
c.add (controlsComponent, BorderLayout.SOUTH);

c.doLayout ();
}
}
}
public static void main(String[] args)
{
PlayClip p = new PlayClip();
try
{
System.out.println((InetAddress.getByName("localhost")).getHo stAddress());
}
catch(Exception e)
{
}
}
}


And I get the followinfg as a result

Unable to handle format: RLE8, 32x32, FrameRate=14.9, Length=2048 1024 extra bytes
Failed to realize: com.sun.media.PlaybackEngine@4a0115
Error: Unable to realize com.sun.media.PlaybackEngine@4a0115

Any idea??? Please I need the solution for my thesis!!
Thanks in advance!!!!!!!!

Topic: FTP client in Java Previous Topic   Next Topic Topic: what is the difference string and stringbuffer?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use