2013-05-08 69 views

回答

2

屏幕截圖在Chrome中作爲實驗性功能提供,您必須在瀏覽器設置中啓用它(chrome:// flags /#enable-usermedia-screen-capture)。而且,它似乎只適用於https連接。

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 
    } 
); 

一旦你設置了視頻,就可以記錄它。有一個爲媒體錄製起草的標準,但它尚未在任何瀏覽器中實現。但是,它仍然是可能的。有關解決方法,請參閱此demo and sample code

不幸的是,目前該解決方案僅適用於Chrome。

+0

您描述的解決方案記錄來自相機的內容,它不是OP請求的截屏。 – pat 2014-10-18 01:05:14

+0

這是因爲這個答案已有一年了,而且實驗功能已被刪除。您現在需要瀏覽器擴展才能使其工作。詳細信息在這裏:https://github.com/muaz-khan/WebRTC-Experiment/tree/master/Pluginfree-Screen-Sharing – brianchirls 2014-10-18 20:51:56