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

会有一股神秘感。 提交于 2019-11-30 19:24:46

问题


Is there some HTML5 API that can help me record the screen (screencast)? I know about recording webcams etc, but I need the screen it self. It would help even more if this API was actually implemented in some cross-platform browser.


回答1:


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.



来源:https://stackoverflow.com/questions/16440120/record-screen-screencast-using-html5-e-g-getusermedia-or-something

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