beecomci / today_i_learned

0 stars 0 forks source link

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() #19

Open beecomci opened 2 years ago

beecomci commented 2 years ago

video Uncaught (in promise) 오류

Case 1

// AS-IS
this.previewVideo.addEventListener('click', event => {
  this.previewPlayer.pause();
  this.playVideo(true);
});

// TO-BE
this.previewPlayer.addEventListener('play', event => {
  this.previewVideo.addEventListener('click', event => {
    this.previewPlayer.pause();
    this.playVideo(true);
  });
});

Case 2

// AS-IS
this.corePlayer.pause();

// TO-BE
const playPromise = this.corePlayer.play();

if (playPromise !== undefined) {
  playPromise
    .then(() => {
      this.corePlayer.pause();
    })
     catch(error => {
      console.err(error);
    }) 
}

참고