[the-board: 7/8] [things] Show sound duration default in time label



commit 5969ac16a8e10832e795d8a99aa84092af45b539
Author: Lucas Rocha <lucasr gnome org>
Date:   Thu Jan 27 17:55:36 2011 +0000

    [things] Show sound duration default in time label

 src/js/ui/things/sound.js |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/js/ui/things/sound.js b/src/js/ui/things/sound.js
index f615a76..816845a 100644
--- a/src/js/ui/things/sound.js
+++ b/src/js/ui/things/sound.js
@@ -88,6 +88,10 @@ SoundThing.prototype = {
                              Lang.bind(this,
                                        this._onPlayerProgressChanged));
 
+        this._player.connect("notify::duration",
+                             Lang.bind(this,
+                                       this._onPlayerDurationChanged));
+
         this._player.connect("notify::state",
                              Lang.bind(this,
                                        this._onPlayerStateChanged));
@@ -198,7 +202,6 @@ SoundThing.prototype = {
     _createTimeLabel : function() {
         this._timeLabel =
             new Mx.Label({ yAlign: Mx.Align.MIDDLE,
-                           text: "00:12:00",
                            anchorY: -2,
                            visible: false,
                            opacity: 0,
@@ -206,7 +209,7 @@ SoundThing.prototype = {
 
         this._timeLabel.set_style(this._style);
 
-        this._updateTimeLabel(0);
+        this._updateTimeLabel(this._player.duration);
 
         this._controlsBox.append(this._timeLabel,
                                  Tb.BoxPackFlags.NONE);
@@ -298,6 +301,9 @@ SoundThing.prototype = {
             // start loading the new sound file
             this._player.filename = this._soundFilename;
 
+            this._player.playing = true;
+            this._player.playing = false;
+
             if (!fromState) {
                 this._playButton.toggled = true;
             }
@@ -519,7 +525,7 @@ SoundThing.prototype = {
         let minutes = Math.floor(currentTime / 60);
         currentTime -= minutes * 60;
 
-        let seconds = currentTime;
+        let seconds = Math.floor(currentTime);
 
         this._timeLabel.text = this._formatTimeComponent(hours) + ":" +
                                this._formatTimeComponent(minutes) + ":" +
@@ -621,16 +627,30 @@ SoundThing.prototype = {
             Math.floor(this._player.duration * this._player.progress);
 
         this._updateProgressBar();
-        this._updateTimeLabel(currentTime);
+
+        if (this._player.progress != 0 &&
+            this._player.duration != 0) {
+            this._updateTimeLabel(currentTime);
+        }
+    },
+
+    _onPlayerDurationChanged : function() {
+        if (this._recorder || this._player.playing) {
+            return;
+        }
+
+        this._updateTimeLabel(this._player.duration);
     },
 
     _onPlayerStateChanged : function() {
         switch(this._player.state) {
         case Tb.SoundPlayerState.IDLE:
             this._updateForSoundLoaded();
+            this._updateTimeLabel(this._player.duration);
             break;
 
         case Tb.SoundPlayerState.DONE:
+            this._updateTimeLabel(this._player.duration);
             break;
 
         case Tb.SoundPlayerState.ERROR:



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