the input goes through the varialbles url and url2------ location of the file
this is the error i get
java.lang.NoClassDefFoundError: javax/media/ControllerListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:12
4)
at sun.applet.AppletClassLoader.findClass(AppletClass Loader.java:162)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.applet.AppletClassLoader.loadClass(AppletClass Loader.java:118)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at sun.applet.AppletClassLoader.loadCode(AppletClassL oader.java:577)
at sun.applet.AppletPanel.createApplet(AppletPanel.ja va:710)
at sun.applet.AppletPanel.runLoader(AppletPanel.java: 639)
at sun.applet.AppletPanel.run(AppletPanel.java:319)
at java.lang.Thread.run(Thread.java:595)
Expand|Select|Wrap|Line Numbers
- import javax.swing.*;
- import javax.media.*;
- import java.awt.*;
- import javax.media.protocol.*;
- import java.net.*;
- import java.util.*;
- //import com.sun.media.util.JMFSecurity;
- /*
- <APPLET CODE = VideoApplet.class WIDTH = 442 HEIGHT = 317 >
- <PARAM NAME = CODE VALUE = VideoApplet.class >
- <PARAM NAME="type" VALUE="application/x-java-applet;version=1.1">
- <PARAM NAME = url VALUE ="FishTank.avi">
- <PARAM NAME = url2 VALUE ="FishTank2.avi">
- </APPLET>
- */
- public class VideoApplet extends JApplet implements ControllerListener
- {
- // component in which video is playing
- Component visualComponent = null;
- // controls gain, position, start, stop
- Component controlComponent = null;
- // displays progress during download
- Component progressBar = null;
- boolean firstTime = true;
- long CachingSize = 0L;
- int controlPanelHeight = 0;
- int videoWidth = 0;
- int videoHeight = 0;
- String url;
- MediaLocator locator;
- Player player;
- boolean f=false;
- JPanel panel= new JPanel();
- HashMap urlmap=new HashMap();
- int loopcnt,looptot;
- public void init(){
- looptot=0;
- String urls=getParameter("url");
- if(urls!=null){
- if(urls.indexOf(",")!=-1){
- StringTokenizer tokens=new StringTokenizer(urls,",");
- while(tokens.hasMoreTokens()){
- String url=tokens.nextToken();
- looptot++;
- System.out.println(" values : "+url+" : "+looptot);
- urlmap.put(String.valueOf(looptot),url);
- }
- }
- else{
- looptot=1;
- urlmap.put(String.valueOf(1),urls);
- }
- }
- loopcnt=0;
- init2();
- }
- public void init2(){
- if(looptot<=0)
- return;
- loopcnt++;
- if(loopcnt>looptot)
- loopcnt=1;
- try {
- url=(String)urlmap.get(String.valueOf(loopcnt));
- URL url2 = new URL(url);
- url = url2.toExternalForm();
- System.out.println(" urlss :: "+url);
- locator = new MediaLocator(url);
- player = Manager.createRealizedPlayer(locator);
- player.addControllerListener(this);
- panel.add(player.getVisualComponent());
- panel.add(player.getControlPanelComponent());
- getContentPane().add(panel);
- //getContentPane().validate();
- player.start();
- } catch (Exception e) {
- System.out.println("ERROR CREATING MEDIALOCATOR"+e);
- System.exit(-1);
- }
- }
- public void start() {
- System.out.println("Applet.start()11 is called");
- // Call start() to prefetch and start the player.
- if (player != null)
- player.start();
- }
- /**
- * Stop media file playback and release resource before
- * leaving the page.
- */
- public void stop() {
- System.out.println("Applet.stop() is called");
- if (player != null) {
- player.stop();
- player.deallocate();
- }
- }
- public void destroy() {
- System.out.println("Applet.destroy() is called");
- player.close();
- }
- public synchronized void controllerUpdate(ControllerEvent event) {
- System.out.println("Event called");
- // If we're getting messages from a dead player,
- // just leave
- if (player == null)
- return;
- if (event instanceof EndOfMediaEvent) {
- stop();
- destroy();
- //getContentPane().removeAll();
- System.out.println("dfdsaf1");
- panel.removeAll();
- //panel.setVisible(false);
- System.out.println("test2");
- init2();
- getContentPane().validate();
- System.out.println("test3");
- //getContentPane().removeAll();
- System.out.println("EndOfMediaEvent5 called");
- }
- // When the player is Realized, get the visual
- // and control components and add them to the Applet
- /*if (event instanceof RealizeCompleteEvent) {
- if (progressBar != null) {
- panel.remove(progressBar);
- progressBar = null;
- }
- int width = getWidth();//520;
- int height = 0;
- if (controlComponent == null)
- if (( controlComponent =
- player.getControlPanelComponent()) != null) {
- controlPanelHeight = controlComponent.getPreferredSize().height;
- panel.add(controlComponent);
- height += controlPanelHeight;
- }
- if (visualComponent == null)
- if (( visualComponent =
- player.getVisualComponent())!= null) {
- panel.add(visualComponent);
- Dimension videoSize = visualComponent.getPreferredSize();
- videoWidth = videoSize.width;
- videoHeight = videoSize.height;
- width = videoWidth;
- height += videoHeight;
- visualComponent.setBounds(0, 0, videoWidth, videoHeight);
- }
- panel.setBounds(0, 0, width, height);
- if (controlComponent != null) {
- controlComponent.setBounds(0, videoHeight,
- width, controlPanelHeight);
- controlComponent.invalidate();
- }
- //player.start();
- } else if (event instanceof CachingControlEvent) {
- if (player.getState() > Controller.Realizing)
- return;
- // Put a progress bar up when downloading starts,
- // take it down when downloading ends.
- CachingControlEvent e = (CachingControlEvent) event;
- CachingControl cc = e.getCachingControl();
- // Add the bar if not already there ...
- if (progressBar == null) {
- if ((progressBar = cc.getControlComponent()) != null) {
- panel.add(progressBar);
- panel.setSize(progressBar.getPreferredSize());
- validate();
- }
- }
- } else if (event instanceof EndOfMediaEvent) {
- System.out.println("Applet.EndOfMediaEvent4() called");
- ///////////////////////////
- } else if (event instanceof ControllerErrorEvent) {
- // Tell TypicalPlayerApplet.start() to call it a day
- System.out.println("Applet errorevent");
- player = null;
- Fatal(((ControllerErrorEvent)event).getMessage());
- } else if (event instanceof ControllerClosedEvent) {
- panel.removeAll();
- }*/
- }
- void Fatal (String s) {
- // Applications will make various choices about what
- // to do here. We print a message
- System.err.println("FATAL ERROR: " + s);
- throw new Error(s); // Invoke the uncaught exception
- // handler System.exit() is another
- // choice.
- }
- }