diff options
author | raylu <raylu@mixpanel.com> | 2011-11-04 01:12:50 -0700 |
---|---|---|
committer | raylu <raylu@mixpanel.com> | 2011-11-04 01:12:50 -0700 |
commit | 4ef8fa20294609b8e2d3c420c2af6c761f127f74 (patch) | |
tree | f6eb29212a7a12db51e11b8273d5acef54ea30c8 /static/script.js | |
parent | 3f0de294ff9450acc84c64c4c6bc890f5c1cd034 (diff) | |
download | audioaxis-4ef8fa20294609b8e2d3c420c2af6c761f127f74.tar.xz |
only show the bar for the current song
Diffstat (limited to 'static/script.js')
-rw-r--r-- | static/script.js | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/static/script.js b/static/script.js index 4701536..8cd72cb 100644 --- a/static/script.js +++ b/static/script.js @@ -73,29 +73,22 @@ function drawBar(id) { var canvas = document.getElementById('c_' + id); if (!canvas) return; canvas.height = canvas.height; //clear - var context = canvas.getContext("2d"); if (current_id == id && player) { + var context = canvas.getContext("2d"); context.fillStyle = dimmedColor; context.fillRect(0, 9, 700, 2); - var loaded_start = player.getVideoStartBytes() / player.getVideoBytesTotal() * 700; - var loaded_length = player.getVideoBytesLoaded() / player.getVideoBytesTotal() * 700; + var loaded_start = player.getVideoStartBytes() / player.getVideoBytesTotal() * 700, + loaded_length = player.getVideoBytesLoaded() / player.getVideoBytesTotal() * 700; context.fillStyle = litColor; context.fillRect(loaded_start, 9, loaded_length, 2); - var current_time = player.getVideoStartBytes() + player.getCurrentTime(); - var current_pos = current_time / player.getDuration() * 690 + 5; + var current_time = player.getVideoStartBytes() + player.getCurrentTime(), + current_pos = current_time / player.getDuration() * 690 + 5; context.beginPath(); context.arc(current_pos, 10, 5, 0, Math.PI * 2, false); context.closePath(); context.fill(); - } else { - context.fillStyle = dimmedColor; - context.beginPath(); - context.arc(5, 10, 5, 0, Math.PI * 2, false); - context.closePath(); - context.fill(); - context.fillRect(0, 9, 700, 2); } } @@ -131,8 +124,9 @@ function onStateChange(state) { function play(yid) { if (current_id != yid) { player.loadVideoById(yid, 0, 'hd720'); - drawBar(current_id, dimmedColor); + var previous_id = current_id; current_id = yid; + drawBar(previous_id); } if (player.getPlayerState() in {'-1':1, '0':1, '5':1}) { // unstarted, ended, cued player.seekTo(0, true); @@ -305,7 +299,6 @@ function drawAdd(s) { .addClass('clear') ) ); - drawBar(s.yid); } function remove(id) { |