Commit 6fc714bf authored by Xiaowu Zhang's avatar Xiaowu Zhang

add loop music switch

parent b4faed88
...@@ -235,6 +235,8 @@ ...@@ -235,6 +235,8 @@
box_context = g.__element.getElementsByClassName("box")[0], box_context = g.__element.getElementsByClassName("box")[0],
filter_context = g.__element.getElementsByClassName("filter")[0], filter_context = g.__element.getElementsByClassName("filter")[0],
filter_type = $('select'), filter_type = $('select'),
loop_context = g.__element.getElementsByClassName("loop")[0],
loop = false,
time_context = g.__element.getElementsByClassName("time")[0]; time_context = g.__element.getElementsByClassName("time")[0];
bar_context.value = 0; bar_context.value = 0;
return new RSVP.Queue() return new RSVP.Queue()
...@@ -244,9 +246,18 @@ ...@@ -244,9 +246,18 @@
}) })
.push(function () { .push(function () {
bar_context.max = g.audio.duration; bar_context.max = g.audio.duration;
return g.plEnablePage(); return RSVP.all([
g.plEnablePage(),
g.plGive("loop")
]);
}) })
.push(function () { .push(function (list) {
if (list[1]) {
loop = true;
loop_context.innerHTML = "loop on";
} else {
loop_context.innerHTML = "loop off";
}
time_context.style.left = bar_context.style.left; time_context.style.left = bar_context.style.left;
$(time_context).offset().top = $(bar_context).offset().top + 3; $(time_context).offset().top = $(bar_context).offset().top + 3;
time_context.innerHTML = timeFormat(g.audio.duration); time_context.innerHTML = timeFormat(g.audio.duration);
...@@ -257,8 +268,13 @@ ...@@ -257,8 +268,13 @@
}), }),
loopEventListener(g.audio, "ended", false, function () { loopEventListener(g.audio, "ended", false, function () {
window.location = g.__element if (loop) {
.getElementsByClassName("next")[0].href; g.audio.load();
g.audio.play();
} else {
window.location = g.__element
.getElementsByClassName("next")[0].href;
}
}), }),
loopEventListener(command_context, "click", false, function () { loopEventListener(command_context, "click", false, function () {
...@@ -289,6 +305,11 @@ ...@@ -289,6 +305,11 @@
false, function () { false, function () {
box_context.style.display = "none"; box_context.style.display = "none";
}), }),
loopEventListener(loop_context, "click", false, function () {
loop_context.innerHTML = loop ? "loop off" : "loop on";
loop = !loop;
return g.plSave({"loop": loop});
}),
myLoopEventListener($(filter_context), "change", function () { myLoopEventListener($(filter_context), "change", function () {
g.filter.frequency.value = filter_context.value; g.filter.frequency.value = filter_context.value;
......
button.loop {
width : 6em;
}
#visualizer { #visualizer {
text-align: center; text-align: center;
} }
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
<div class="time" style="position:relative;"> <div class="time" style="position:relative;">
</div> </div>
<button type="button" class="loop" ></button>
<div id="visualizer"> <div id="visualizer">
<canvas id="can" width="800" height="350"> <canvas id="can" width="800" height="350">
!Canvas not supported by your browser !Canvas not supported by your browser
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
</ul> </ul>
</div> </div>
<div class="info">
</div>
<div data-role="footer" data-position="fixed" data-theme="b"> <div data-role="footer" data-position="fixed" data-theme="b">
<div data-role="navbar" > <div data-role="navbar" >
......
...@@ -60,7 +60,8 @@ ...@@ -60,7 +60,8 @@
}) })
.fail(function (error) { .fail(function (error) {
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
console.log("error"); gadget.__element.getElementsByClassName('info')[0].innerHTML =
"please enable local server";
} }
}); });
}) })
......
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