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

add loop music switch

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