Record screen (screencast) using HTML5, e.g. getUserMedia or something?

强颜欢笑 提交于 2019-12-01 00:32:10

Screen capture is available as an experimental feature in Chrome, and you must enable it in your browser settings (chrome://flags/#enable-usermedia-screen-capture). Also, it seems to only work on an https connection.

navigator.getUserMedia({
    video: {
      mandatory: {
        chromeMediaSource: 'screen'
        // maxWidth: 640,
        // maxHeight: 480
      }
    }
  },
  function (stream) {
    //success! Now set up the video
    var video = document.createElement('video');
    video.src = window.URL.createObjectURL(stream);
    video.autoplay = true;
    //you can choose to display the video here or not.
  },
  function () {
    //failure. browser is unable or permission denied
  }
);

Once you have the video set up, it is possible to record it. There is a standard drafted for media recording, but it's not implemented in any browsers yet. However, it is still possible. Refer to this demo and sample code for a workaround.

Unfortunately, for now, this solution is available for Chrome only.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!