[the-board/time-label-fix: 3/4] partial work on time label for recording time



commit 8e2a1e2563cd9803d64c146be75bb4dc003fbf71
Author: Lucas Rocha <lucasr gnome org>
Date:   Thu Jan 27 00:49:03 2011 +0000

    partial work on time label for recording time

 src/js/ui/things/sound.js |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/js/ui/things/sound.js b/src/js/ui/things/sound.js
index 94485a7..742dd40 100644
--- a/src/js/ui/things/sound.js
+++ b/src/js/ui/things/sound.js
@@ -204,7 +204,7 @@ SoundThing.prototype = {
 
         this._timeLabel.set_style(this._style);
 
-        this._updateTimeLabel();
+        this._updateTimeLabel(0);
 
         this._controlsBox.append(this._timeLabel,
                                  Tb.BoxPackFlags.NONE);
@@ -407,6 +407,10 @@ SoundThing.prototype = {
         this._recorder =
             new Tb.SoundRecorder({ filename: filename });
 
+        this._recorder.connect("notify::duration",
+                               Lang.bind(this,
+                                         this._onRecorderDurationChanged));
+
         this._stopButton =
             new Mx.Button({ label: Gettext.gettext("Stop"),
                             y: _STOP_BUTTON_Y,
@@ -504,10 +508,7 @@ SoundThing.prototype = {
         return (n >= 10 ? n : "0" + n);
     },
 
-    _updateTimeLabel : function() {
-        let currentTime =
-            Math.floor(this._player.duration * this._player.progress);
-
+    _updateTimeLabel : function(currentTime) {
         let hours = Math.floor(currentTime / 3600);
         currentTime -= hours * 3600;
 
@@ -570,6 +571,10 @@ SoundThing.prototype = {
         this._setSpoolsAnimating(this._playButton.toggled);
     },
 
+    _onRecorderDurationChanged : function() {
+        this._updateTimeLabel(this._recorder.duration);
+    },
+
     _onStopButtonClicked : function() {
         this._stopVoiceRecording();
         this._startEditingCaption();
@@ -586,8 +591,11 @@ SoundThing.prototype = {
     },
 
     _onPlayerProgressChanged : function() {
+        let currentTime =
+            Math.floor(this._player.duration * this._player.progress);
+
         this._updateProgressBar();
-        this._updateTimeLabel();
+        this._updateTimeLabel(currentTime);
     },
 
     _onPlayerStateChanged : function() {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]