unpause: Don't resume autodetection if not paused

This commit is contained in:
Tamius Han 2022-08-08 23:17:13 +02:00
parent c12a04b55f
commit ec4d43d2ec

View File

@ -298,15 +298,20 @@ class ArDetector {
stop() { stop() {
if (this.animationFrameHandle) { if (this.animationFrameHandle) {
this.logger.log('info', 'debug', `"%c[ArDetect::stop] <@${this.arid}> Stopping AnimationFrame loop.`, _ard_console_stop); this.logger.log('info', 'debug', `%c[ArDetect::stop] <@${this.arid}> Stopping AnimationFrame loop.`, _ard_console_stop);
window.cancelAnimationFrame(this.animationFrameHandle); window.cancelAnimationFrame(this.animationFrameHandle);
} else { } else {
this.logger.log('info', 'debug', `"%c[ArDetect::stop] <@${this.arid}> AnimationFrame loop is already paused (due to an earlier call of this function).`); this.logger.log('info', 'debug', `%c[ArDetect::stop] <@${this.arid}> AnimationFrame loop is already paused (due to an earlier call of this function).`);
} }
} }
unpause() { unpause() {
// unpause only when paused, otherwise we get an unnecessary reset
if (this._paused) {
this.startLoop(); this.startLoop();
} else {
this.logger.log('info', 'debug', `%c[ArDetect::unpause] <@${this.arid} We are trying to unpause video, but video is not paused. This is potentially haram.`, 'color: #ff0');
}
} }
pause() { pause() {