From c833e01bbb7ada309db8908957be5e9b3d4c49ac Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Thu, 30 May 2002 17:59:22 +0000 Subject: [PATCH] Code cleanups. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2516 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/src/com/tightvnc/rfbplayer/ButtonPanel.java | 13 +++++++------ java/src/com/tightvnc/rfbplayer/RfbPlayer.java | 15 ++++++++++----- java/src/com/tightvnc/rfbplayer/RfbProto.java | 6 +++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java index 0a67090c..3b4f2756 100644 --- a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java +++ b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java @@ -28,7 +28,7 @@ class ButtonPanel extends Panel implements ActionListener { protected TextField posText; protected TextField timeScaleText; - protected int lastPos = -1; + protected int lastPosSeconds = -1; ButtonPanel(RfbPlayer player) { this.player = player; @@ -64,11 +64,12 @@ class ButtonPanel extends Panel implements ActionListener { playButton.setEnabled(true); } - public void setPos(int pos) { - if (pos != lastPos) { - lastPos = pos; + public void setPos(long pos) { + int seconds = (int)(pos / 1000); + if (seconds != lastPosSeconds) { + lastPosSeconds = seconds; char[] zeroes = {'0', '0', '0', '0'}; - String text = String.valueOf(pos); + String text = String.valueOf(seconds); if (text.length() < 4) { text = new String(zeroes, 0, 4 - text.length()) + text; } @@ -85,7 +86,7 @@ class ButtonPanel extends Panel implements ActionListener { if (evt.getSource() == playButton) { player.setPaused(playButton.getLabel().equals("Pause")); } else if (evt.getSource() == posText) { - player.setPos(Integer.parseInt(posText.getText())); + player.setPos(Long.parseLong(posText.getText()) * 1000); } else if (evt.getSource() == timeScaleText) { double speed = Double.parseDouble(timeScaleText.getText()); if (speed <= 0.0) diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java index 4a600169..1d725f92 100644 --- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java +++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java @@ -57,6 +57,7 @@ public class RfbPlayer extends java.applet.Applet VncCanvas vc; String sessionURL; + URL url; long initialTimeOffset; double playbackSpeed; boolean showControls; @@ -118,7 +119,7 @@ public class RfbPlayer extends java.applet.Applet } try { - URL url = new URL(sessionURL); + url = new URL(sessionURL); rfb = new RfbProto(url); vc = new VncCanvas(this); @@ -158,7 +159,7 @@ public class RfbPlayer extends java.applet.Applet while (true) { try { setPaused(true); - rfb.fbs.setTimeOffset(initialTimeOffset); + setPos(initialTimeOffset); rfb.fbs.setSpeed(playbackSpeed); vc.processNormalProtocol(); } catch (EOFException e) { @@ -195,14 +196,18 @@ public class RfbPlayer extends java.applet.Applet rfb.fbs.setSpeed(speed); } - public void setPos(int pos) { - rfb.fbs.setTimeOffset(pos * 1000); + public void setPos(long pos) { + if (pos > rfb.fbs.getTimeOffset()) { + rfb.fbs.setTimeOffset(pos); + } else { + System.out.println("Seeking backwards is not implemented yet."); + } } public void updatePos() { if (showControls) - buttonPanel.setPos((int)(rfb.fbs.getTimeOffset() / 1000)); + buttonPanel.setPos(rfb.fbs.getTimeOffset()); } // diff --git a/java/src/com/tightvnc/rfbplayer/RfbProto.java b/java/src/com/tightvnc/rfbplayer/RfbProto.java index 2faf66c0..58140120 100644 --- a/java/src/com/tightvnc/rfbplayer/RfbProto.java +++ b/java/src/com/tightvnc/rfbplayer/RfbProto.java @@ -86,6 +86,10 @@ class RfbProto { newSession(url); } + // + // Open new session URL. + // + public void newSession(URL url) throws Exception { if (fbs != null) fbs.close(); @@ -100,7 +104,7 @@ class RfbProto { } // - // Read server's protocol version message + // Read server's protocol version message. // int serverMajor, serverMinor; -- 2.39.5