summaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-08-01 02:34:41 -0700
committerraylu <raylu@mixpanel.com>2011-08-01 02:34:41 -0700
commitf9803a3bbfb3e730213825d6dc332b7c31321330 (patch)
tree486553d015e100e87dd7f37daeaf65fea38a86fd /static
parent5395b5ada15dfc417cbe789ea3297274f050892d (diff)
downloadaudioaxis-f9803a3bbfb3e730213825d6dc332b7c31321330.tar.xz
use new exp/template, make stuff work
Diffstat (limited to 'static')
-rw-r--r--static/audioaxis-white.pngbin0 -> 10190 bytes
-rw-r--r--static/base.css54
-rw-r--r--static/player_pause.pngbin0 -> 398 bytes
-rw-r--r--static/player_play.pngbin0 -> 520 bytes
-rw-r--r--static/player_stop.pngbin0 -> 370 bytes
-rw-r--r--static/script.js99
6 files changed, 153 insertions, 0 deletions
diff --git a/static/audioaxis-white.png b/static/audioaxis-white.png
new file mode 100644
index 0000000..0d1e779
--- /dev/null
+++ b/static/audioaxis-white.png
Binary files differ
diff --git a/static/base.css b/static/base.css
new file mode 100644
index 0000000..d2a4ada
--- /dev/null
+++ b/static/base.css
@@ -0,0 +1,54 @@
+body {
+ background-color: #000;
+ color: #ccc;
+ font-family: sans-serif;
+}
+a:link, a:visited {
+ color: #08a;
+ text-decoration: none;
+}
+a:hover {
+ color: #0af;
+ text-decoration: underline;
+}
+img {
+ border-style: none;
+ vertical-align: middle;
+}
+
+header, article {
+ width: 900px;
+ margin: 20px auto;
+}
+
+object#player {
+ position: absolute;
+ left: -1px;
+ top: 0;
+}
+
+section.song {
+ background-color: #111;
+ padding: 15px 20px;
+ margin-top: 10px;
+}
+section.song .info {
+ margin-bottom: 10px;
+}
+section.song div.thumb {
+ float: left;
+ width: 150px;
+ overflow: hidden;
+}
+section.song canvas, section.song > img {
+ position: relative;
+ top: 20px;
+}
+section.song > img[src$='pause.png'] {
+ display: none;
+}
+
+.clear {
+ line-height: 0;
+ clear: both;
+}
diff --git a/static/player_pause.png b/static/player_pause.png
new file mode 100644
index 0000000..c384034
--- /dev/null
+++ b/static/player_pause.png
Binary files differ
diff --git a/static/player_play.png b/static/player_play.png
new file mode 100644
index 0000000..d863e4e
--- /dev/null
+++ b/static/player_play.png
Binary files differ
diff --git a/static/player_stop.png b/static/player_stop.png
new file mode 100644
index 0000000..740bed0
--- /dev/null
+++ b/static/player_stop.png
Binary files differ
diff --git a/static/script.js b/static/script.js
new file mode 100644
index 0000000..21e01d0
--- /dev/null
+++ b/static/script.js
@@ -0,0 +1,99 @@
+var player;
+var litColor = '#eee';
+var dimmedColor = '#555';
+var interval;
+for (var i = 0; i < ids.length; i++) {
+ drawBar(ids[i]);
+}
+
+function drawBar(id) {
+ var canvas = document.getElementById(id);
+ canvas.height = canvas.height; //clear
+ var context = canvas.getContext("2d");
+
+ if (current_id == id && player) {
+ 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;
+ 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;
+ 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);
+ }
+}
+
+function onYouTubePlayerReady(playerId) {
+ player = document.getElementById('player');
+ player.addEventListener('onStateChange', 'onStateChange');
+}
+
+function onStateChange(state) {
+ switch (state) {
+ case 1: //playing
+ interval = setInterval(drawBar, 100, current_id);
+ break;
+ case 0: //ended
+ showPlay(current_id);
+ case -1: //unstarted
+ case 2: //paused
+ case 3: //buffering
+ case 5: //cued
+ clearInterval(interval);
+ }
+}
+
+function play(yid) {
+ if (current_id != yid) {
+ player.loadVideoById(yid, 0, 'hd720');
+ drawBar(current_id, dimmedColor);
+ current_id = yid;
+ }
+ if (player.getPlayerState() in {'-1':1, '0':1, '5':1}) { // unstarted, ended, cued
+ player.seekTo(0, true);
+ }
+ player.playVideo();
+ for (var i = 0; i < ids.length; i++) {
+ if (ids[i] == yid)
+ showPause(ids[i]);
+ else
+ showPlay(ids[i]);
+ }
+}
+function pause(yid) {
+ if (current_id != yid)
+ return
+ player.pauseVideo();
+ showPlay(yid)
+}
+function stop(yid) {
+ if (current_id != yid)
+ return
+ player.stopVideo();
+ showPlay(yid)
+}
+
+function showPlay(yid) {
+ var play = document.getElementById('play_' + yid);
+ var pause = document.getElementById('pause_' + yid);
+ play.style.display = 'inline';
+ pause.style.display = 'none';
+}
+function showPause(yid) {
+ var pause = document.getElementById('pause_' + yid);
+ var play = document.getElementById('play_' + yid);
+ pause.style.display = 'inline';
+ play.style.display = 'none';
+}