473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

trouble with executing applets!!!! pl help

This is a code i wrote to play a video file usin JMF..... the applet gets started but not initialized..... is the code correct or is there any mistake?????? please help me out as soon as u can......need to get this right as soon as i can.........

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
  1. import javax.swing.*;
  2. import javax.media.*;
  3. import java.awt.*;
  4. import javax.media.protocol.*;
  5. import java.net.*;
  6. import java.util.*;
  7. //import com.sun.media.util.JMFSecurity;
  8. /*
  9. <APPLET CODE = VideoApplet.class WIDTH = 442 HEIGHT = 317 >
  10. <PARAM NAME = CODE VALUE = VideoApplet.class >
  11. <PARAM NAME="type" VALUE="application/x-java-applet;version=1.1">
  12. <PARAM NAME = url VALUE ="FishTank.avi">
  13. <PARAM NAME = url2 VALUE ="FishTank2.avi">
  14. </APPLET>
  15. */
  16. public class VideoApplet extends JApplet implements ControllerListener
  17. {
  18.    // component in which video is playing
  19.     Component visualComponent = null;
  20.     // controls gain, position, start, stop
  21.     Component controlComponent = null;
  22.     // displays progress during download
  23.     Component progressBar = null;
  24.     boolean firstTime = true;
  25.     long CachingSize = 0L;    
  26.         int controlPanelHeight = 0;
  27.     int videoWidth = 0;
  28.     int videoHeight = 0;
  29.     String url;
  30.     MediaLocator locator;
  31.     Player player;
  32.     boolean f=false;
  33.     JPanel panel= new JPanel();
  34.     HashMap urlmap=new HashMap();
  35.     int loopcnt,looptot;
  36. public void init(){
  37.  
  38. looptot=0;
  39. String urls=getParameter("url");
  40. if(urls!=null){
  41.     if(urls.indexOf(",")!=-1){
  42.         StringTokenizer tokens=new StringTokenizer(urls,",");
  43.         while(tokens.hasMoreTokens()){
  44.             String url=tokens.nextToken();
  45.             looptot++;
  46.             System.out.println(" values : "+url+"  : "+looptot);
  47.             urlmap.put(String.valueOf(looptot),url);
  48.         }
  49.     }
  50.     else{
  51.         looptot=1;    
  52.         urlmap.put(String.valueOf(1),urls);
  53.     }
  54. }    
  55.         loopcnt=0;
  56.  
  57.         init2();
  58.     }
  59. public void init2(){
  60. if(looptot<=0)
  61.     return;
  62. loopcnt++;
  63. if(loopcnt>looptot)
  64.     loopcnt=1;
  65.     try {
  66.                url=(String)urlmap.get(String.valueOf(loopcnt));
  67.                URL url2 = new URL(url);
  68.         url = url2.toExternalForm();
  69.         System.out.println(" urlss :: "+url);
  70.             locator = new MediaLocator(url);
  71.             player = Manager.createRealizedPlayer(locator);    
  72.             player.addControllerListener(this);
  73.             panel.add(player.getVisualComponent());
  74.             panel.add(player.getControlPanelComponent());
  75.             getContentPane().add(panel);
  76.             //getContentPane().validate();
  77.             player.start();
  78.         } catch (Exception e) {
  79.             System.out.println("ERROR CREATING MEDIALOCATOR"+e);
  80.             System.exit(-1);
  81.         }
  82.     }
  83.       public void start() {
  84.  System.out.println("Applet.start()11 is called");
  85.         // Call start() to prefetch and start the player.
  86.         if (player != null)
  87.         player.start();
  88.     }
  89.     /**
  90.      * Stop media file playback and release resource before
  91.      * leaving the page.
  92.      */
  93.     public void stop() {
  94.      System.out.println("Applet.stop() is called");
  95.         if (player != null) {
  96.             player.stop();
  97.             player.deallocate();
  98.         }
  99.     }
  100.     public void destroy() {
  101.      System.out.println("Applet.destroy() is called");
  102.     player.close();
  103.     }
  104.       public synchronized void controllerUpdate(ControllerEvent event) {
  105.         System.out.println("Event called");
  106.     // If we're getting messages from a dead player, 
  107.     // just leave
  108.     if (player == null)
  109.         return;
  110.  
  111. if (event instanceof EndOfMediaEvent) {
  112. stop();
  113. destroy();
  114.  
  115.     //getContentPane().removeAll();
  116.     System.out.println("dfdsaf1");
  117.     panel.removeAll();
  118.     //panel.setVisible(false);
  119.     System.out.println("test2");
  120.     init2();
  121.     getContentPane().validate();
  122.     System.out.println("test3");
  123.     //getContentPane().removeAll();
  124. System.out.println("EndOfMediaEvent5  called");
  125. }
  126.  
  127.  
  128.     // When the player is Realized, get the visual 
  129.     // and control components and add them to the Applet
  130.     /*if (event instanceof RealizeCompleteEvent) {
  131.         if (progressBar != null) {
  132.         panel.remove(progressBar);
  133.         progressBar = null;
  134.         }
  135.  
  136.         int width = getWidth();//520;
  137.         int height = 0;
  138.         if (controlComponent == null)
  139.         if (( controlComponent = 
  140.               player.getControlPanelComponent()) != null) {
  141.  
  142.             controlPanelHeight = controlComponent.getPreferredSize().height;
  143.             panel.add(controlComponent);
  144.             height += controlPanelHeight;
  145.         }
  146.         if (visualComponent == null)
  147.         if (( visualComponent =
  148.               player.getVisualComponent())!= null) {
  149.             panel.add(visualComponent);
  150.             Dimension videoSize = visualComponent.getPreferredSize();
  151.             videoWidth = videoSize.width;
  152.             videoHeight = videoSize.height;
  153.             width = videoWidth;
  154.             height += videoHeight;
  155.             visualComponent.setBounds(0, 0, videoWidth, videoHeight);
  156.         }
  157.  
  158.         panel.setBounds(0, 0, width, height);
  159.         if (controlComponent != null) {
  160.         controlComponent.setBounds(0, videoHeight,
  161.                        width, controlPanelHeight);
  162.         controlComponent.invalidate();
  163.         }
  164.         //player.start();
  165.  
  166.      } else if (event instanceof CachingControlEvent) {
  167.         if (player.getState() > Controller.Realizing)
  168.         return;
  169.         // Put a progress bar up when downloading starts, 
  170.         // take it down when downloading ends.
  171.         CachingControlEvent e = (CachingControlEvent) event;
  172.         CachingControl cc = e.getCachingControl();
  173.  
  174.         // Add the bar if not already there ...
  175.         if (progressBar == null) {
  176.             if ((progressBar = cc.getControlComponent()) != null) {
  177.             panel.add(progressBar);
  178.             panel.setSize(progressBar.getPreferredSize());
  179.             validate();
  180.         }
  181.         }
  182.     } else if (event instanceof EndOfMediaEvent) {
  183.  
  184.  
  185.     System.out.println("Applet.EndOfMediaEvent4() called");
  186.         ///////////////////////////
  187.  
  188.  
  189.     } else if (event instanceof ControllerErrorEvent) {
  190.         // Tell TypicalPlayerApplet.start() to call it a day
  191.         System.out.println("Applet errorevent");
  192.         player = null;
  193.         Fatal(((ControllerErrorEvent)event).getMessage());
  194.         } else if (event instanceof ControllerClosedEvent) {
  195.         panel.removeAll();
  196.     }*/
  197.  
  198.  
  199.     }
  200.  
  201.     void Fatal (String s) {
  202.     // Applications will make various choices about what
  203.     // to do here. We print a message
  204.     System.err.println("FATAL ERROR: " + s);
  205.     throw new Error(s); // Invoke the uncaught exception
  206.                 // handler System.exit() is another
  207.                 // choice.
  208.  
  209.     }
  210. }
  211.  
Jan 30 '08 #1
3 1467
BigDaddyLH
1,216 Expert 1GB
It seems the java plugin doesn't have access to package javax.media. That's not part of the J2SE, right? How do you expect a client machine to access this package?
Jan 30 '08 #2
It seems the java plugin doesn't have access to package javax.media. That's not part of the J2SE, right? How do you expect a client machine to access this package?
i've installed JMF... the code i downloaded from ine internet works...... but not mine..... i wanna make mine work....
Jan 30 '08 #3
BigDaddyLH
1,216 Expert 1GB
i've installed JMF... the code i downloaded from ine internet works...... but not mine..... i wanna make mine work....
The problems are arising because you are writing an applet. Why not write your example as a standalone application?
Jan 30 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fork | last post by:
Hi, I am trying to execute a script from the command line as follows; c:\program files\mysql\bin>mysql -u root newsman < servers3.mysql But this gives me the following error; ERROR 1064...
4
by: zmcelrath87 | last post by:
I am having a problem involving the scope of timeouts and intervals. Since timeouts and intervals execute in the global scope, dynamically generated local interval/timeout declarations do not work,...
9
by: Don | last post by:
I'm trying to run the following page on my desktop from my host server. It works just fine if I run it from my desktop, but not if I run it from the server. I get "Error: Permission denied" on...
1
by: Alvo von Cossel I | last post by:
yo dudes, i have a form with a helpbox in the controlbox. normally when you click the helpbox the cursor changes to a question mark and when you click somerthing, a help tooltip comes up. how do...
0
by: dba123 | last post by:
I have read and tried stuff in the following articles: http://support.microsoft.com/kb/896054/...
2
by: vvenk | last post by:
Hello: I wrote a test procedure on Oracle that returns a string and a value. CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload ( P_ERROR OUT VARCHAR2, P_ERROR_NO ...
8
by: Daz | last post by:
Hi everyone. I was faced with the choice of whether my problem is indeed a PHP problem or a MySQL. I have decided it's a PHP problem as I don't experience the same problem when I execute the...
1
by: Jeff | last post by:
ASP.NET 2.0 This stored procedure fails because the variable type contains a number. I've debugged the SP in VS2005 and it works if I change the 0/1 value of type to true/false... How should I...
7
by: RawMustard | last post by:
Hi Folks, my first post here. Sorry to start with a request. I'm having trouble executing python scripts compiled to byte code on ubuntu feisty server version. Basically I can type ./MyScript.py...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.