From c23aeb0fede14fa779be02e15aa6d322998b0e75 Mon Sep 17 00:00:00 2001 From: "wimba.com" Date: Thu, 16 Sep 2004 00:00:00 +0000 Subject: [PATCH] A set of changes from HorizonLive/Wimba: - package name set to com.HorizonLive.RfbPlayer; - reducing the screen size by 30 pixels in each direction; - interface to control RfbPlayer from other applets (RfbSharedStatic); - applets to control RfbPlayer (PARfbSender, RfbPlayerSetDisplaySize); - new jumpTo(long pos) method of RfbPlayer that can be called via PARfbSender. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2530 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- .../com/tightvnc/rfbplayer/ButtonPanel.java | 2 ++ .../tightvnc/rfbplayer/FbsInputStream.java | 2 ++ .../com/tightvnc/rfbplayer/PARfbSender.java | 19 ++++++++++++++++++ .../src/com/tightvnc/rfbplayer/RfbPlayer.java | 16 +++++++++++++++ .../rfbplayer/RfbPlayerSetDisplaySize.java | 20 +++++++++++++++++++ java/src/com/tightvnc/rfbplayer/RfbProto.java | 5 +++++ .../tightvnc/rfbplayer/RfbSharedStatic.java | 9 +++++++++ .../src/com/tightvnc/rfbplayer/VncCanvas.java | 14 +++++++++++++ 8 files changed, 87 insertions(+) create mode 100644 java/src/com/tightvnc/rfbplayer/PARfbSender.java create mode 100644 java/src/com/tightvnc/rfbplayer/RfbPlayerSetDisplaySize.java create mode 100644 java/src/com/tightvnc/rfbplayer/RfbSharedStatic.java diff --git a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java index 95a7eb62..306c62ec 100644 --- a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java +++ b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java @@ -17,6 +17,8 @@ // USA. // +package com.HorizonLive.RfbPlayer; + import java.awt.*; import java.awt.event.*; import java.io.*; diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java index 1dcdd093..5547c3c7 100644 --- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java +++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java @@ -21,6 +21,8 @@ // FbsInputStream.java // +package com.HorizonLive.RfbPlayer; + import java.io.*; import java.util.*; diff --git a/java/src/com/tightvnc/rfbplayer/PARfbSender.java b/java/src/com/tightvnc/rfbplayer/PARfbSender.java new file mode 100644 index 00000000..1f620cfa --- /dev/null +++ b/java/src/com/tightvnc/rfbplayer/PARfbSender.java @@ -0,0 +1,19 @@ + +package com.HorizonLive.RfbPlayer; + +import java.applet.*; + +public class PARfbSender extends Applet { + + public void init() { + Applet receiver = null; + receiver = RfbSharedStatic.refApplet; + long time = Long.valueOf(getParameter("time")).longValue(); + + if (receiver != null) { + ((RfbPlayer)receiver).jumpTo(time); + } else + System.out.println("Couldn't jump to time: " + time + " in RfbPlayer."); + } + +} diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java index 0918bef1..c46c769c 100644 --- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java +++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java @@ -18,6 +18,8 @@ // USA. // +package com.HorizonLive.RfbPlayer; + import java.awt.*; import java.awt.event.*; import java.io.*; @@ -68,6 +70,9 @@ public class RfbPlayer extends java.applet.Applet // public void init() { + // LiveConnect work-a-round + RfbSharedStatic.refApplet = this; + readParameters(); if (inSeparateFrame) { @@ -208,6 +213,17 @@ public class RfbPlayer extends java.applet.Applet rfb.fbs.setSpeed(speed); } + public void jumpTo(long pos) { + long diff = Math.abs(pos - rfb.fbs.getTimeOffset()); + + // Current threshold is 5 seconds + if (diff > 5000) { + rfb.fbs.pausePlayback(); + setPos(pos); + rfb.fbs.resumePlayback(); + } + } + public void setPos(long pos) { rfb.fbs.setTimeOffset(pos); } diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayerSetDisplaySize.java b/java/src/com/tightvnc/rfbplayer/RfbPlayerSetDisplaySize.java new file mode 100644 index 00000000..917b1122 --- /dev/null +++ b/java/src/com/tightvnc/rfbplayer/RfbPlayerSetDisplaySize.java @@ -0,0 +1,20 @@ + +package com.HorizonLive.RfbPlayer; + +import java.applet.*; + +public class RfbPlayerSetDisplaySize extends Applet { + + public void init() { + Applet receiver = null; + receiver = RfbSharedStatic.refApplet; + int width = Integer.valueOf(getParameter("DISPLAY_WIDTH")).intValue(); + int height = Integer.valueOf(getParameter("DISPLAY_HEIGHT")).intValue(); + + if (receiver != null) { + ((RfbPlayer)receiver).displaySize(width, height); + } else + System.out.println("Couldn't resize RfbPlayer."); + } + +} diff --git a/java/src/com/tightvnc/rfbplayer/RfbProto.java b/java/src/com/tightvnc/rfbplayer/RfbProto.java index e8a5042b..8f341df5 100644 --- a/java/src/com/tightvnc/rfbplayer/RfbProto.java +++ b/java/src/com/tightvnc/rfbplayer/RfbProto.java @@ -24,6 +24,8 @@ // RfbProto.java // +package com.HorizonLive.RfbPlayer; + import java.io.*; import java.awt.*; import java.awt.event.*; @@ -100,6 +102,9 @@ class RfbProto { byte[] b = new byte[12]; + for (int i = 0; i < b.length; i++) + b[i] = (byte)'0'; + is.readFully(b); if ((b[0] != 'R') || (b[1] != 'F') || (b[2] != 'B') || (b[3] != ' ') || diff --git a/java/src/com/tightvnc/rfbplayer/RfbSharedStatic.java b/java/src/com/tightvnc/rfbplayer/RfbSharedStatic.java new file mode 100644 index 00000000..377ede3c --- /dev/null +++ b/java/src/com/tightvnc/rfbplayer/RfbSharedStatic.java @@ -0,0 +1,9 @@ + +package com.HorizonLive.RfbPlayer; + +import java.applet.*; + +public class RfbSharedStatic { + + public static Applet refApplet; +} diff --git a/java/src/com/tightvnc/rfbplayer/VncCanvas.java b/java/src/com/tightvnc/rfbplayer/VncCanvas.java index 57bb8588..3b4a30b9 100644 --- a/java/src/com/tightvnc/rfbplayer/VncCanvas.java +++ b/java/src/com/tightvnc/rfbplayer/VncCanvas.java @@ -20,6 +20,8 @@ // USA. // +package com.HorizonLive.RfbPlayer; + import java.awt.*; import java.awt.event.*; import java.awt.image.*; @@ -184,6 +186,18 @@ class VncCanvas extends Canvas implements Observer { Dimension screenSize = player.vncFrame.getToolkit().getScreenSize(); Dimension frameSize = player.vncFrame.getSize(); Dimension newSize = frameSize; + + // Reduce Screen Size by 30 pixels in each direction; + // This is a (poor) attempt to account for + // 1) Menu bar on Macintosh (should really also account for + // Dock on OSX). Usually 22px on top of screen. + // 2) Taxkbar on Windows (usually about 28 px on bottom) + // 3) Other obstructions. + + screenSize.height -= 30; + screenSize.width -= 30; + + boolean needToResizeFrame = false; if (frameSize.height > screenSize.height) { newSize.height = screenSize.height; -- 2.39.5