Firefox: drawImage(video) fails with NS_ERROR_NOT_AVAILABLE: Component is not available

淺唱寂寞╮ 提交于 2019-12-05 04:06:31

This is a bug in Firefox. The easiest fix is to simply keep trying until the error goes away, since no event fires at the correct time.

See: http://jsfiddle.net/9aT63/25/

Basically, you have to wrap the drawImage call in a try/catch block.

function drawVideo() {
  try {
    $vidCanvasCtx.drawImage($vid, 0, 0, $vidCanvas.width, $vidCanvas.height);
    ...
  } catch (e) {
    if (e.name == "NS_ERROR_NOT_AVAILABLE") {
      // Wait a bit before trying again; you may wish to change the
      // length of this delay.
      setTimeout(drawVideo, 100);
    } else {
      throw e;
    }
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!