home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-24 | 4.4 KB | 161 lines |
- /////////////////////////////////////////////////////////////////////////////
-
- // ClickAndPlayApplet.java
-
- //
-
- // Extremely simple java applet sample that uses the high level RAPlayer native
-
- // method class.
-
- //
-
- // Copyright (c) 1996 by Progressive Networks, Inc.
-
- // All Rights Reserved.
-
- //
-
- //
-
- import java.awt.*;
-
- import java.applet.*;
-
- import netscape.javascript.JSException;
-
- import netscape.javascript.JSObject;
-
- import RAObserver;
-
- import RAPlayer;
-
-
-
- /////////////////////////////////////////////////////////////////////////////
-
- //
-
- // Class:
-
- //
-
- // ClickAndPlayApplet
-
- //
-
- // Purpose:
-
- //
-
- // Variation on Scribble Applet. Implements an extremely simple
-
- // Java applet that demonstrates the use of the RAPlayer object.
-
- // Extends the applet class demonstrating the use of the RealAudio
-
- // native method in Netscape.
-
- //
-
- public class ClickAndPlayApplet extends Applet{
-
- int lastx = 0;
-
- int lasty = 0;
-
- static boolean firstTime;
-
-
-
- public void init() {
-
- firstTime=true;
-
- }
-
-
-
- public boolean mouseMove(Event e, int x, int y){
-
-
-
- if (firstTime) {
-
- firstTime=false;
-
- System.out.println("FirstTime! " + firstTime);
-
- JSObject win = JSObject.getWindow(this);
-
- JSObject doc = (JSObject) win.getMember("document");
-
-
-
- RAPlayer ra = (RAPlayer)doc.getMember("javaPlug1");
-
- ra.DoPlayPause();
-
- lastx=x;
-
- lasty=y;
-
-
-
- }
-
- return true;
-
- }
-
-
-
- /////////////////////////////////////////////////////////////////////////////
-
- //
-
- // Method:
-
- //
-
- // ClickAndPlayApplet.mouseDown()
-
- //
-
- // Purpose:
-
- //
-
- // Store x, y mouse position. Begin playing RealAudio file.
-
- //
-
- // Parameters:
-
- //
-
- // Event e
-
- // Java event.
-
- //
-
- // int x
-
- // x coordinate of mouse position.
-
- //
-
- // int y
-
- // y coordinate of mouse position.
-
- //
-
- // Return Value:
-
- //
-
- // Boolean.
-
- //
-
- public boolean mouseDown(Event e, int x, int y){
-
- JSObject win = JSObject.getWindow(this);
-
- JSObject doc = (JSObject) win.getMember("document");
-
-
-
- RAPlayer ra = (RAPlayer)doc.getMember("javaPlug1");
-
- ra.DoPlayPause();
-
- lastx=x;
-
- lasty=y;
-
- return true;
-
- }
-
-
-
- /////////////////////////////////////////////////////////////////////////////
-
- //
-
- // Method:
-
- //
-
- // ClickAndPlayApplet.mouseUp()
-
- //
-
- // Purpose:
-
- //
-
- // Store x, y mouse position. Pause RealAudio file.
-
- //
-
- // Parameters:
-
- //
-
- // Event e
-
- // Java event.
-
- //
-
- // int x
-
- // x coordinate of mouse position.
-
- //
-
- // int y
-
- // y coordinate of mouse position.
-
- //
-
- // Return Value:
-
- //
-
- // Boolean.
-
- //
-
- public boolean mouseUp(Event e, int x, int y){
-
- JSObject win = JSObject.getWindow(this);
-
- JSObject doc = (JSObject) win.getMember("document");
-
-
-
- RAPlayer ra = (RAPlayer)doc.getMember("javaPlug1");
-
- ra.DoPlayPause();
-
- return true;
-
- }
-
-
-
- /////////////////////////////////////////////////////////////////////////////
-
- //
-
- // Method:
-
- //
-
- // ClickAndPlayApplet.mouseDrag()
-
- //
-
- // Purpose:
-
- //
-
- // Draw line from old mouse position to new mouse position.
-
- //
-
- // Parameters:
-
- //
-
- // Event e
-
- // Java event.
-
- //
-
- // int newx
-
- // new x coordinate of mouse position.
-
- //
-
- // int newy
-
- // new y coordinate of mouse position.
-
- //
-
- // Return Value:
-
- //
-
- // Boolean.
-
- //
-
-
-
- public boolean mouseDrag(Event e, int newx, int newy){
-
- Graphics g=getGraphics();
-
- g.drawLine(lastx, lasty, newx, newy);
-
- lastx=newx;
-
- lasty=newy;
-
- return true;
-
- }
-
- }
-
-