Added support for new "Position" parameter.
Fixed a NullPointerException with "Show Controls"="no".
Documented all supported parameters.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2512 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java
index cbfffc9..7a1e888 100644
--- a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java
+++ b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java
@@ -64,7 +64,6 @@
       posText.setEditable(false);
     }
     playButton.setEnabled(true);
-    player.setPaused(paused);
   }
 
   public void setPos(int pos) {
@@ -86,7 +85,7 @@
 
   public void actionPerformed(ActionEvent evt) {
     if (evt.getSource() == playButton) {
-      setPaused(playButton.getLabel().equals("Pause"));
+      player.setPaused(playButton.getLabel().equals("Pause"));
     } else if (evt.getSource() == posText) {
       player.setPos(Integer.parseInt(posText.getText()));
     }
diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
index f5aeb2d..d47953a 100644
--- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
+++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
@@ -116,7 +116,7 @@
     return timeOffset;
   }
 
-  public synchronized void setTimeOffset(int pos)
+  public synchronized void setTimeOffset(long pos)
   {
     // FIXME: Seeking works only in paused mode.
     paused = true;
diff --git a/java/src/com/tightvnc/rfbplayer/README b/java/src/com/tightvnc/rfbplayer/README
index 4a3a72e..1661652 100644
--- a/java/src/com/tightvnc/rfbplayer/README
+++ b/java/src/com/tightvnc/rfbplayer/README
@@ -2,14 +2,63 @@
 RFB Session Player 0.7.0
 ========================
 
-RFB Session Player is a Java application/applet for playing back RFB
-session files in FBS format saved by such programs as VNC Reflector or
-rfbproxy.
+RFB Session Player is a Java application/applet for playing back RFB session
+files in FBS format saved by such programs as VNC Reflector or rfbproxy.
 
-Usage:  java RfbPlayer URL file:test.fbs
+Usage:  java RfbPlayer URL file:test.fbs position 5000
         java RfbPlayer URL http://remote.host/sessions/test.fbs
 
 
+Applet Parameters
+=================
+
+--> "URL"
+
+    Value: URL of the session file to play.
+    Default: none (required parameter).
+
+    This parameter tells the player which session file to play. Please note
+    that if the player operates as an unsigned applet, it is able to play
+    only files from the host where the applet was loaded from. It's a usual
+    JVM security limitation.
+
+--> "Position"
+
+    Value: time in milliseconds.
+    Default: 0.
+
+    Set initial time position in the session file, in milliseconds.
+
+--> "Open new window" (applicable only in the applet mode)
+
+    Values: "Yes", "No".
+    Default: "No".
+
+    Operate in a separate window. This makes possible resizing the desktop,
+    and adds scroll bars when necessary. If the server supports variable
+    desktop size, the window will resize automatically when remote desktop
+    size changes.
+
+--> "Show controls"
+
+    Values: "Yes", "No".
+    Default: "Yes".
+
+    Set to "No" if you want to get rid of the control panel at the top. 
+    Please note that hiding the panel in current version makes playback
+    impossible. :-)
+
+--> "Defer screen updates"
+
+    Value: time in milliseconds.
+    Default: "20".
+
+    When updating the desktop contents after reading each update, schedule
+    repaint within the specified number of milliseconds. Small delay helps to
+    coalesce several small updates into one drawing operation, improving CPU
+    usage. Set this parameter to 0 to disable deferred updates.
+
+
 Licensing Terms
 ===============
 
diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
index 099148b..0d87006 100644
--- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
+++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
@@ -59,6 +59,7 @@
   VncCanvas vc;
 
   String sessionURL;
+  long initialTimeOffset;
   boolean showControls;
   int deferScreenUpdates;
 
@@ -158,9 +159,11 @@
 
       while (true) {
 	try {
-	  buttonPanel.setPaused(true);
+	  setPaused(true);
+	  fbsStream.setTimeOffset(initialTimeOffset);
 	  vc.processNormalProtocol();
 	} catch (EOFException e) {
+	  initialTimeOffset = 0;
 	  fbsStream.close();
 	  fbsStream = new FbsInputStream(url.openStream());
 	  rfb.newInputStream(fbsStream);
@@ -177,6 +180,8 @@
   }
 
   public void setPaused(boolean paused) {
+    if (showControls)
+      buttonPanel.setPaused(paused);
     if (fbsStream != null) {
       if (paused) {
 	fbsStream.pausePlayback();
@@ -191,7 +196,8 @@
   }
 
   public void updatePos() {
-    buttonPanel.setPos((int)(fbsStream.getTimeOffset() / 1000));
+    if (showControls)
+      buttonPanel.setPos((int)(fbsStream.getTimeOffset() / 1000));
   }
 
   //
@@ -204,6 +210,7 @@
   public void readParameters() {
 
     sessionURL = readParameter("URL", true);
+    initialTimeOffset = readLongParameter("Position", 0);
 
     showControls = true;
     String str = readParameter("Show Controls", false);
@@ -217,7 +224,9 @@
     }
 
     // Fine tuning options.
-    deferScreenUpdates = readIntParameter("Defer screen updates", 20);
+    deferScreenUpdates = (int)readLongParameter("Defer screen updates", 20);
+    if (deferScreenUpdates < 0)
+      deferScreenUpdates = 0;	// Just in case.
   }
 
   public String readParameter(String name, boolean required) {
@@ -247,12 +256,12 @@
     return null;
   }
 
-  int readIntParameter(String name, int defaultValue) {
+  long readLongParameter(String name, long defaultValue) {
     String str = readParameter(name, false);
-    int result = defaultValue;
+    long result = defaultValue;
     if (str != null) {
       try {
-	result = Integer.parseInt(str);
+	result = Long.parseLong(str);
       } catch (NumberFormatException e) { }
     }
     return result;