Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillUnmount() {
// 清除定时器和事件监听
this.interval && clearInterval(this.interval);
this.timeoutVolume && clearTimeout(this.timeoutVolume);
this.timeoutQuality && clearTimeout(this.timeoutQuality);
this.timeoutSetting && clearTimeout(this.timeoutSetting);
window.removeEventListener("mouseup");
screenfull.off("change");
}
return () => {
if (screenfull.isEnabled) {
screenfull.off('change', onChange);
}
};
}, [onChange]);
destroyEvents.push(() => {
screenfull.off('change', screenfullChange);
screenfull.off('error', screenfullError);
});
}
componentWillUnmount() {
screenfull.off('change', this.updateState)
}
private _onChange(): void {
if (!screenfull) {
return;
}
if (screenfull.isFullscreen) {
window.addEventListener('resize', this._resizeListener);
this._adjustSizeForFullscreen();
} else {
this._resetSize();
window.removeEventListener('resize', this._resizeListener);
screenfull.off('change', this._changeListener);
this._engaged = false;
}
}
destroyEvents.push(() => {
screenfull.off('change', screenfullChange);
screenfull.off('error', screenfullError);
});
}
private destroyListeners(): void {
if (screenfull && screenfull.off) {
screenfull.off('change', this.onFullscreenChange);
}
clearInterval(this.statsInterval);
this.leftPlayer.htmlPlayer.removeEventListener('canplaythrough', this.onCanPlayThrough);
this.leftPlayer.htmlPlayer.removeEventListener('ended', this.onEnded);
this.leftPlayer.htmlPlayer.removeEventListener('loadstart', this.onLoadStart);
this.leftPlayer.htmlPlayer.removeEventListener('pause', this.onPause);
this.leftPlayer.htmlPlayer.removeEventListener('play', this.onPlay);
this.leftPlayer.htmlPlayer.removeEventListener('seeked', this.onSeeked);
this.leftPlayer.htmlPlayer.removeEventListener('seeking', this.onSeeking);
this.leftPlayer.htmlPlayer.removeEventListener('timeupdate', this.onTimeUpdate);
this.rightPlayer.htmlPlayer.removeEventListener('canplaythrough', this.onCanPlayThrough);
this.rightPlayer.htmlPlayer.removeEventListener('ended', this.onEnded);
this.leftPlayer.htmlPlayer.removeEventListener('pause', this.onPause);
destroy() {
if (screenfull.enabled) {
screenfull.off('change', this.change)
}
},
},
componentWillUnmount() {
screenfull.off("change", this._handleFullscreenChange);
}