AgoraIO-Community / AgoraWebSDK-NG

The Next Generation of Agora Web SDK
https://agoraio-community.github.io/AgoraWebSDK-NG/
161 stars 75 forks source link

AbortError: The play() request was interrupted by a new load request. https://goo.gl/LdLk22 #25

Open MobeenAshraf opened 4 years ago

MobeenAshraf commented 4 years ago

Getting following error:

AbortError: The play() request was interrupted by a new load request. https://goo.gl/LdLk22

It leads to getting audio but doesn't create a video player. The error itself is quite intermittent but has occurred quite a few times now.

From the link: https://goo.gl/LdLk22, mentioned with error, I can see that play method can be a promise and we can do something like:

 var playPromise = video.play();

  if (playPromise !== undefined) {
    playPromise.then(_ => {
      // Automatic playback started!
      // Show playing UI.
    })
    .catch(error => {
      // Auto-play was prevented
      // Show paused UI.
    });
  }
disoul commented 4 years ago

This AbortError is caused by calling Track.stop() immediately after calling Track.play(), not caused by the autoplay policy. In Agora Web SDK NG, videoTrack.play() will not use Promise to call HTMLVideoElement.play, because there is no autoplay problem in videoTrack.play, SDK's <video> tag does not have any audio source and this <video> tag's muted attribute is true.

If you want to catch the autoplay error in SDK, you should use this callback onAudioAutoplayFailed.

MobeenAshraf commented 4 years ago

I am not calling stop for remote players. I am calling stop for local track when I am muting/stopping video only

disoul commented 4 years ago

Ok, You can ignore this warning now. We will hide this warning in the future.

MobeenAshraf commented 4 years ago

This may be unrelated (and I am not yet able to confirm for now) but whenever this error appears the video container also doesn't appear. I may be able to confirm this if required

vvedharaju commented 4 years ago

are you using react? could this also be from multiple re-renders triggering play on the same video if there are back to re-renders?

MobeenAshraf commented 4 years ago

I am using react but it shouldn't be from multiple re-renders.

play is called on user-published and I also un-subscribe on componentWillUnMount.

I will try to post some more details/logs