Skip to content

Commit

Permalink
fix: cleanup event listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed May 21, 2024
1 parent 85aceb1 commit 0bdbfd5
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class VideoElementManager {
removeVideoElement(videoElement: HTMLVideoElement): void {
this.track.removeSink(videoElement);
this.videoElements.delete(videoElement);
videoElement.removeEventListener('play', this.resumeVideoPlayback);
videoElement.removeEventListener('pause', this.resumeVideoPlayback);
this.entries.delete(videoElement);
this.resizeObserver?.unobserve(videoElement);
this.intersectionObserver?.unobserve(videoElement);
Expand Down Expand Up @@ -182,6 +184,8 @@ export class VideoElementManager {
cleanup = () => {
this.videoElements.forEach(videoElement => {
videoElement.srcObject = null;
videoElement.removeEventListener('play', this.resumeVideoPlayback);
videoElement.removeEventListener('pause', this.resumeVideoPlayback);
this.resizeObserver?.unobserve(videoElement);
this.intersectionObserver?.unobserve(videoElement);
});
Expand Down

0 comments on commit 0bdbfd5

Please sign in to comment.