From 666af88cab4a37b08062c7d94f783ea16cc5a07e Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 22 Apr 2013 17:26:44 +0100 Subject: [PATCH] Added total duration label --- static/css/com.podnoms.player.css | 8 +- static/js/app/views/mix.js | 11 +- static/js/com.podnoms.player.js | 24 +-- templates/views/_MixItemInsert.html | 247 ++++++++++++++-------------- 4 files changed, 152 insertions(+), 138 deletions(-) diff --git a/static/css/com.podnoms.player.css b/static/css/com.podnoms.player.css index 46f1adc..90ebb5c 100644 --- a/static/css/com.podnoms.player.css +++ b/static/css/com.podnoms.player.css @@ -99,7 +99,8 @@ div.player-body ul.player-controls a { } .waveform { - background-color: #404040 + background-color: #404040; + position: relative; } .waveform img { @@ -227,3 +228,8 @@ img.mix-listing-image { font-size: 72%; text-align: center; } + +.dss-time-display-label-total { + right: 0; + width: 46px; +} \ No newline at end of file diff --git a/static/js/app/views/mix.js b/static/js/app/views/mix.js index 6c6c58d..941ccdb 100644 --- a/static/js/app/views/mix.js +++ b/static/js/app/views/mix.js @@ -38,7 +38,15 @@ window.MixListItemView = Backbone.View.extend({ com.podnoms.player.drawTimeline( $('#player-timeline-' + id, this.el), + $('#mix-container-' + id, this.el), this.model.get('duration')); + + var totalDuration = moment.duration(this.model.get('duration'), "seconds"); + var totalDurationText = totalDuration.hours() != 0 ? + moment(totalDuration).format("HH:mm:ss") : + moment(totalDuration).format("mm:ss"); + + $('#player-duration-' + id, this.el).text(totalDurationText); return this; }, mouseOverProfile: function () { @@ -148,8 +156,7 @@ window.MixListItemView = Backbone.View.extend({ } ); } -}) -; +}); window.MixListView = Backbone.View.extend({ itemPlaying: null, diff --git a/static/js/com.podnoms.player.js b/static/js/com.podnoms.player.js index b7eaa6f..2f650e2 100644 --- a/static/js/com.podnoms.player.js +++ b/static/js/com.podnoms.player.js @@ -134,7 +134,7 @@ com.podnoms.player = { isPlayingId: function (id) { return this.isPlaying() && this.currentSound.sID == "com.podnoms.player-" + id; }, - drawTimeline: function (el, duration) { + drawTimeline: function (el, boundingEl, duration) { /* Assume 10 markers */ @@ -142,12 +142,13 @@ com.podnoms.player = { var item = $(document.createElement("li")); this.soundDuration = duration * 1000; //convert to milliseconds for (var i = 0; i < 10; i++) { - var duration = moment.duration(markerDuration * (i + 1), "seconds"); - var text = duration.hours() != 0 ? - moment(duration).format("HH:mm") : - moment(duration).format("mm:ss"); + var sliceDuration = moment.duration(markerDuration * (i + 1), "seconds"); + var text = sliceDuration.hours() != 0 ? + moment(sliceDuration).format("HH:mm") : + moment(sliceDuration).format("mm:ss"); el.append(item.clone().text(text).css('width', '10%')); } + }, setupPlayer: function (options) { this._parseOptions(options); @@ -179,21 +180,20 @@ com.podnoms.player = { ref.play(); if (options.success) options.success(); + //create the floating time display label + this.timeDisplayLabel = $('