Commit 8d1e93b5 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add volume control in control gadget

parent a1c0707c
...@@ -22,22 +22,9 @@ ...@@ -22,22 +22,9 @@
.declareMethod('playSong', function () { .declareMethod('playSong', function () {
this.audio.play(); this.audio.play();
}) })
.declareMethod('volumeUp', function () { .declareMethod('setVolume', function (volume) {
var gadget = this; this.volume = volume;
if (gadget.volume < 3) { this.gain.gain.value = volume;
gadget.volume += 0.2;
}
gadget.gain.gain.value = gadget.volume;
})
.declareMethod('volumeDowm', function () {
var gadget = this;
if (gadget.volume > 0) {
gadget.volume -= 0.2;
if (gadget.volume < 0) {
gadget.volume = 0;
}
}
gadget.gain.gain.value = gadget.volume;
}) })
.declareMethod('getVolume', function () { .declareMethod('getVolume', function () {
return Math.round(this.volume * 100) + "%"; return Math.round(this.volume * 100) + "%";
...@@ -90,7 +77,7 @@ ...@@ -90,7 +77,7 @@
gadget.buffer = buffer; gadget.buffer = buffer;
resolve(buffer); resolve(buffer);
}, function () { }, function () {
reject(-1); reject("decode error");
}); });
}); });
}).then(function (response) { }).then(function (response) {
......
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