home *** CD-ROM | disk | FTP | other *** search
- /*
- */
- import AviObserver;
- import AviPlayer;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.awt.Button;
- import java.awt.Event;
- import java.awt.BorderLayout;
- import java.awt.Frame;
- import java.applet.Applet;
- import netscape.javascript.JSObject;
-
- /**
- * An interactive test of the Graphics.drawArc and Graphics.fillArc
- * routines. Can be run either as a standalone application by
- * typing "java ArcTest" or as an applet in the AppletViewer.
- */
- public class AviTest extends Applet implements AviObserver{
- MediaControl control;
-
- public void init() {
- setLayout(new BorderLayout());
- add("Center", control = new MediaControl(getDocument()));
- control.enable();
- }
-
- public static void main(String args[]) {
- Frame f = new Frame("AviTest");
- AviTest aviTest = new AviTest();
-
- aviTest.init();
-
- f.add("Center", aviTest);
- f.resize(300, 30);
- f.show();
- }
-
- public void onStop() {
- control.resetButton();
- }
-
- public void onPositionChange(int newPosition) {
- control.updateFrame(newPosition);
- }
-
- public JSObject getDocument() {
- return (JSObject)JSObject.getWindow(this).getMember("document");
- }
-
- }
-
-
- class MediaControl extends Panel {
- TextField s;
- Button play;
- Button stop;
-
- JSObject document;
-
- public MediaControl(JSObject doc) {
- document = doc;
-
- add(play = new Button("Play"));
- add(stop = new Button("Stop"));
- add(s = new TextField("0", 4));
- stop.disable();
- }
-
- public void updateFrame(int frame) {
- s.setText(String.valueOf(frame));
- }
-
- public void resetButton() {
- play.enable();
- stop.disable();
- }
-
- public boolean action(Event ev, Object arg) {
- if (ev.target instanceof Button) {
- AviPlayer avi = (AviPlayer)document.getMember("avi");
-
- String label = (String)arg;
- if (label == "Play") {
- // look AviPlayer.java for exaplanation
- avi.play(true);
- play.disable();
- stop.enable();
- return true;
- }
- else {
- // look AviPlayer.java for exaplanation
- avi.stop(true);
- stop.disable();
- play.enable();
- return true;
- }
- }
-
- return false;
- }
-
- }
-
-