Commit 66adf726 authored by Xiaowu Zhang's avatar Xiaowu Zhang

combine play/pause command

parent 46e356eb
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
that, that,
next_context, next_context,
play_context, play_context,
stop_context,
addMusic_context, addMusic_context,
list_context, list_context,
currentId = -1, currentId = -1,
...@@ -27,7 +26,7 @@ ...@@ -27,7 +26,7 @@
titleSave, titleSave,
playlist = []; playlist = [];
function nextId() { function nextId() {
if (totalId === -1) { if (totalId <= 0) {
return -1; return -1;
} }
currentId += 1; currentId += 1;
...@@ -79,7 +78,6 @@ ...@@ -79,7 +78,6 @@
var array = g.__element.getElementsByTagName('a'); var array = g.__element.getElementsByTagName('a');
next_context = array[0]; next_context = array[0];
play_context = array[1]; play_context = array[1];
stop_context = array[array.length - 3];
addMusic_context = array[array.length - 2]; addMusic_context = array[array.length - 2];
list_context = array[array.length - 1]; list_context = array[array.length - 1];
that = g; that = g;
...@@ -130,13 +128,9 @@ ...@@ -130,13 +128,9 @@
}); });
}, 1000); }, 1000);
volume.setMax(3); volume.setMax(3);
that.showPage("play").then(function (result) {
play_context.href = result;
});
that.showPage("stop").then(function (result) { that.showPage("stop").then(function (result) {
stop_context.href = result; play_context.href = result;
}); });
that.showPage("addMusic").then(function (result) { that.showPage("addMusic").then(function (result) {
addMusic_context.href = result; addMusic_context.href = result;
}); });
...@@ -165,7 +159,6 @@ ...@@ -165,7 +159,6 @@
animation.display(); animation.display();
next_context.style.display = ""; next_context.style.display = "";
play_context.style.display = ""; play_context.style.display = "";
stop_context.style.display = "";
addMusic_context.style.display = ""; addMusic_context.style.display = "";
list_context.style.display = ""; list_context.style.display = "";
}) })
...@@ -176,7 +169,6 @@ ...@@ -176,7 +169,6 @@
animation.noDisplay(); animation.noDisplay();
next_context.style.display = "none"; next_context.style.display = "none";
play_context.style.display = "none"; play_context.style.display = "none";
stop_context.style.display = "none";
addMusic_context.style.display = "none"; addMusic_context.style.display = "none";
list_context.style.display = "none"; list_context.style.display = "none";
}) })
...@@ -199,6 +191,7 @@ ...@@ -199,6 +191,7 @@
if (options.page === "addMusic") { if (options.page === "addMusic") {
animation.stopAnimation(); animation.stopAnimation();
that.noDisplay(); that.noDisplay();
list.noDisplay();
io.display(); io.display();
return; return;
} }
...@@ -206,6 +199,7 @@ ...@@ -206,6 +199,7 @@
if (options.page === "playlist") { if (options.page === "playlist") {
animation.stopAnimation(); animation.stopAnimation();
that.noDisplay(); that.noDisplay();
io.noDisplay();
list.initList(playlist); list.initList(playlist);
list.display(); list.display();
return; return;
...@@ -217,11 +211,19 @@ ...@@ -217,11 +211,19 @@
that.display(); that.display();
if (options.page === "play") { if (options.page === "play") {
that.showPage("stop").then(function (result) {
play_context.href = result;
play_context.innerHTML = "stop";
});
control.playSong(); control.playSong();
animation.showAnimation(); animation.showAnimation();
return; return;
} }
if (options.page === "stop") { if (options.page === "stop") {
that.showPage("play").then(function (result) {
play_context.href = result;
play_context.innerHTML = "play";
});
control.stopSong(); control.stopSong();
animation.stopAnimation(); animation.stopAnimation();
return; return;
...@@ -246,6 +248,11 @@ ...@@ -246,6 +248,11 @@
animation.showAnimation(); animation.showAnimation();
}); });
}); });
} else {
error.noDisplay();
list.noDisplay();
io.noDisplay();
that.display();
} }
}); });
}(window, rJS, jQuery, RSVP)); }(window, rJS, jQuery, RSVP));
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<div data-role="navbar"> <div data-role="navbar">
<ul> <ul>
<li> <a class="next">next</a></li> <li> <a class="next">next</a></li>
<li> <a class="play">play</a></li> <li> <a class="play">stop</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
<div data-role="footer" data-position="fullscreen"> <div data-role="footer" data-position="fullscreen">
<div data-role="navbar"> <div data-role="navbar">
<ul> <ul>
<li> <a class="stop">stop</a></li>
<li> <a class="addMusic">addMusic</a></li> <li> <a class="addMusic">addMusic</a></li>
<li> <a href="#page=playlist">playlist</a></li> <li> <a href="#page=playlist">playlist</a></li>
</ul> </ul>
......
...@@ -65,13 +65,16 @@ ...@@ -65,13 +65,16 @@
.declareMethod("display", function (options) { .declareMethod("display", function (options) {
this.canvas.style.display = ""; this.canvas.style.display = "";
this.mirror.style.display = ""; this.mirror.style.display = "";
this.visualize.style.display = "";
}) })
.declareMethod("noDisplay", function (options) { .declareMethod("noDisplay", function (options) {
this.canvas.style.display = "none"; this.canvas.style.display = "none";
this.mirror.style.display = "none"; this.mirror.style.display = "none";
this.visualize.style.display = "none";
}); });
gk.ready(function (g) { gk.ready(function (g) {
g.visualize = g.__element.getElementsByTagName('div')[0];
g.canvas = g.__element.getElementsByTagName('canvas')[0]; g.canvas = g.__element.getElementsByTagName('canvas')[0];
g.mirror = g.__element.getElementsByTagName('canvas')[1]; g.mirror = g.__element.getElementsByTagName('canvas')[1];
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
input_context; input_context;
gk.declareMethod('createIO', function (description, key) { gk.declareMethod('createIO', function (description, key) {
// indexedDB.deleteDatabase("jio:test"); // indexedDB.deleteDatabase("jio:test");
this.jio = jIO.createJIO(description); this.jio = jIO.createJIO(description);
this.key = key; this.key = key;
return this.jio.put({ return this.jio.put({
...@@ -70,10 +70,12 @@ ...@@ -70,10 +70,12 @@
"m") "m")
.then(function () { .then(function () {
g.showAllIO().then(function (result) { g.showAllIO().then(function (result) {
var array = Object.keys(result), if (result !== undefined) {
i; var array = Object.keys(result),
for (i = 0; i < array.length; i += 1) { i;
g.playlist.push(array[i]); for (i = 0; i < array.length; i += 1) {
g.playlist.push(array[i]);
}
} }
g.sendPlaylist(g.playlist); g.sendPlaylist(g.playlist);
}); });
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
var i, var i,
docFragment = document.createDocumentFragment(), docFragment = document.createDocumentFragment(),
li; li;
// this.list.innerHTML = ""; this.list.innerHTML = "";
for (i = 0; i < array.length; i += 1) { for (i = 0; i < array.length; i += 1) {
li = document.createElement("li"); li = document.createElement("li");
li.innerHTML = li.innerHTML =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment