Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Java Player/Applet

Posted on 2004-11-25
14
Medium Priority
?
1,052 Views
Last Modified: 2013-11-23
Hi Guys. I am trying to get an applet to play a mpeg file through an html page and I have it setup like below. Every time I run it, it gives an error saying that Applet PlayerApplet notinited. I'm sure i'm doing something wrong.
Please help (Btw - the video clip is called mmvcd.mpeg and all these files/html/class etc are on my desktop)

If another approach is better to make this play thats cool too. Just need something ultra simple.
Thanks kindly

The html page says:
-----------------------
<HTML>
<HEAD><TITLE>Test Program</TITLE></HEAD>
<BODY>


<APPLET CODE=PlayerApplet
WIDTH=352 HEIGHT=240>
<PARAM NAME=FILE VALUE="mmvcd.mpeg">
</APPLET>

</BODY>
</HTML>




The Java Code Says:
------------------------
import java.applet.*;
import java.awt.*;
import java.net.*;
import javax.media.*;

public class PlayerApplet extends Applet implements ControllerListener {
   Player player = null;
   public void init() {
      setLayout(new BorderLayout());
      String mediaFile = getParameter("FILE");
      try {
         URL mediaURL = new URL(getDocumentBase(), mediaFile);
         player = Manager.createPlayer(mediaURL);
         player.addControllerListener(this);
      }
      catch (Exception e) {
         System.err.println("Got exception "+e);
      }
   }
   public void start() {
      player.start();
   }
   public void stop() {
      player.stop();
      player.deallocate();
   }
   public void destroy() {
      player.close();
   }
   public synchronized void controllerUpdate(ControllerEvent event) {
      if (event instanceof RealizeCompleteEvent) {
         Component comp;
         if ((comp = player.getVisualComponent()) != null)
            add ("Center", comp);
         if ((comp = player.getControlPanelComponent()) != null)
            add ("South", comp);         
         validate();
      }
   }
}

0
Comment
Question by:pauldhadialla
  • 4
  • 4
  • 3
  • +1
14 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12674900
I don't believe you can just use the javax.media classes in an applet
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:pauldhadialla
ID: 12675731
Thanks Tim, any suggestion on how I can run a basic mpeg file with a applet. Still very new fo JMF here.

Regards.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12676662
AFAIK, Java does not ordinarily support mpeg. See http://www.alphaworks.ibm.com/tech/mpeg-4
0
 

Author Comment

by:pauldhadialla
ID: 12676729
CEHJ - i'm even trying .mov files and .wmv files and I keep getting this error saying Applet PlayerApplet "notinited"

I check the plug-in settings for Java Plug-in too and they seem to be ok for my browser (IE)
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1000 total points
ID: 12676736
Have a look for exceptions in the plugin console
0
 

Author Comment

by:pauldhadialla
ID: 12677081
CEHJ where is this plug-in console you are referring to?

I did go into IE options and started using the Microsoft VM and now the error doesn't come up any more
It just says done and no video.
Hmm
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12677411
>>CEHJ where is this plug-in console you are referring to?

That varies depending on what browser version you're using. The following may help:

http://www.fitwise.com/testjava.asp
0
 
LVL 92

Expert Comment

by:objects
ID: 12677795
Is the plugin set as the default VM for your browser? and do you have JMF installed?
0
 
LVL 92

Expert Comment

by:objects
ID: 12677804
ie. you need both

(and jmf does support mpeg)
0
 

Author Comment

by:pauldhadialla
ID: 12678053
Objects - i have installed JMF yes, and fixed the classpath to point to the jmf and sound jar files

The default VM for my browser - I tried using both the MS version and the JAVA one. When i have the MS version enabled, the error Applet PlayerApplet "notinited"
 goes away from IE - and it just says Done. When i turn it on for IE - it gives me the same error

I even downloaded Netscape 7.2 and it also gives me that error Applet PlayerApplet "notinited".


CEHJ - here is the ouput from the console after I open my web page and i get the error (using Sun Java JVM) - if I use MS VM then no output in console - but no video in applet either.

java.lang.NoClassDefFoundError: javax/media/ControllerListener

      at java.lang.ClassLoader.defineClass0(Native Method)

      at java.lang.ClassLoader.defineClass(Unknown Source)

      at java.security.SecureClassLoader.defineClass(Unknown Source)

      at sun.applet.AppletClassLoader.findClass(Unknown Source)

      at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)

      at java.lang.ClassLoader.loadClass(Unknown Source)

      at sun.applet.AppletClassLoader.loadClass(Unknown Source)

      at java.lang.ClassLoader.loadClass(Unknown Source)

      at sun.applet.AppletClassLoader.loadCode(Unknown Source)

      at sun.applet.AppletPanel.createApplet(Unknown Source)

      at sun.plugin.AppletViewer.createApplet(Unknown Source)

      at sun.applet.AppletPanel.runLoader(Unknown Source)

      at sun.applet.AppletPanel.run(Unknown Source)

      at java.lang.Thread.run(Unknown Source)

0
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 12678066
looks like jmf is not installed on the client correctly
i'd suggest copying the jars to the jre's 'ext' directory (<jre>/lib/ext)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12679997
8-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question