From fe079839e4bc1e84d902e7682330c7726a4a0a4f Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Wed, 29 May 2002 00:52:32 +0000 Subject: [PATCH] Text field in the ButtonPanel to show current time offset in seconds. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2507 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- .../com/tightvnc/rfbplayer/ButtonPanel.java | 20 +++++++++++++++++++ .../tightvnc/rfbplayer/FbsInputStream.java | 5 +++++ .../src/com/tightvnc/rfbplayer/RfbPlayer.java | 4 ++++ .../src/com/tightvnc/rfbplayer/VncCanvas.java | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java index e7cabb58..62fa88b3 100644 --- a/java/src/com/tightvnc/rfbplayer/ButtonPanel.java +++ b/java/src/com/tightvnc/rfbplayer/ButtonPanel.java @@ -26,6 +26,9 @@ class ButtonPanel extends Panel implements ActionListener { protected RfbPlayer player; protected Button playButton; protected Button pauseButton; + protected TextField posText; + + protected int lastPos = -1; ButtonPanel(RfbPlayer player) { this.player = player; @@ -41,6 +44,10 @@ class ButtonPanel extends Panel implements ActionListener { pauseButton.setEnabled(false); add(pauseButton); pauseButton.addActionListener(this); + + posText = new TextField(4); + posText.setEditable(false); + add(posText); } public void setMode(int mode) { @@ -68,6 +75,19 @@ class ButtonPanel extends Panel implements ActionListener { player.setMode(mode); } + public void setPos(int pos) { + if (pos != lastPos) { + lastPos = pos; + char[] zeroes = {'0', '0', '0', '0'}; + String text = String.valueOf(pos); + if (text.length() < 4) { + text = new String(zeroes, 0, 4 - text.length()) + text; + } + posText.setText(text); + posText.setCaretPosition(text.length()); + } + } + // // Event processing. // diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java index fab854be..59418d9e 100644 --- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java +++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java @@ -101,6 +101,11 @@ class FbsInputStream extends InputStream { // Methods providing additional functionality. // + public int getPos() + { + return (int)(timeOffset / 1000); + } + public void resumeReading() { startTime = System.currentTimeMillis() - timeOffset; diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java index 58d4d640..741736eb 100644 --- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java +++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java @@ -194,6 +194,10 @@ public class RfbPlayer extends java.applet.Applet } } + public void updatePos() { + buttonPanel.setPos(fbsStream.getPos()); + } + // // readParameters() - read parameters from the html source or from the // command line. On the command line, the arguments are just a sequence of diff --git a/java/src/com/tightvnc/rfbplayer/VncCanvas.java b/java/src/com/tightvnc/rfbplayer/VncCanvas.java index 58d24dea..f421df59 100644 --- a/java/src/com/tightvnc/rfbplayer/VncCanvas.java +++ b/java/src/com/tightvnc/rfbplayer/VncCanvas.java @@ -208,6 +208,8 @@ class VncCanvas extends Canvas { zlibInflater = new Inflater(); tightInflaters = new Inflater[4]; + player.updatePos(); + // Main dispatch loop. while (true) { @@ -482,6 +484,8 @@ class VncCanvas extends Canvas { throw new IOException("Unknown RFB message type " + msgType); } + player.updatePos(); + if (player.getMode() == player.MODE_STOPPED) { throw new EOFException("Playback stopped"); } -- 2.39.5