title: Unhandled Rejection (AbortError): The fetching process for the media resource was aborted by the user agent at the user's request
body: <p><a href="https://onoumenon.gitbook.io/wiki/programming/tips/rtmp" rel="nofollow noreferrer">https://onoumenon.gitbook.io/wiki/programming/tips/rtmp</a></p>
  <pre><code>    buildPlayer() {
      if (this.player || !this.props.stream) {
        return;
      }
      const { id } = this.props.match.params;
      this.player = flv.createPlayer({
        type: &quot;flv&quot;,
        url: `http://localhost:8000/live/${id}.flv`
      });
      this.player.attachMediaElement(this.videoRef.current);
      this.player.load();
    }
  </code></pre>
  <p>I am trying to use this code to stream videos to users, but I get an error, if there are no stream and the app crashes.</p>
  <p>Unhandled Rejection (AbortError): The fetching process for the media resource was aborted by the user agent at the user's request.</p>
  <p>The error is thrown when I try to execute this:</p>
  <p>player.attachMediaElement(videoRef.current);</p>
  <p>Is there a way to check if this line is going to throw an error?</p>