Fix background music stuttering

I finally got to reading the SM2 documentation more closely, and saw:

> precision can vary between 20 msec to perhaps 0.5 seconds and the
> sound's position property will reflect this delta when the
> onPosition() callback fires

Emphasis on "this.position will reflect this delta".

Anyway, this new system should have significantly less noticeable
stuttering.
This commit is contained in:
Guangcong Luo
2016-12-11 05:29:21 -05:00
parent d66779e7e7
commit 763cfb01f0

View File

@@ -92,8 +92,8 @@ var BattleSoundLibrary = (function () {
// suppress crash
return (this.bgmCache[url] = this.soundPlaceholder);
}
this.bgmCache[url].onposition(loopend, function () {
this.setPosition(loopstart);
this.bgmCache[url].onposition(loopend, function (evP) {
this.setPosition(this.position - (loopend - loopstart));
});
return this.bgmCache[url];
};