Mac*_*cik 1 javascript webrtc typescript
我有一个简单的问题。是否有可能实现适用于大多数设备和浏览器的屏幕共享?
我在互联网上查找,发现了一些 chrome 插件,但我想在不安装任何插件或在 chrome 上设置一些实验标志的情况下进行屏幕共享。
最好的解决方案是当我可以从导航器中进行流传输时,就像我的相机捕获一样。
从相机获取视频的代码
this.navig.getUserMedia = ( this.navig.getUserMedia || this.navig.webkitGetUserMedia || this.navig.mozGetUserMedia || this.navig.msGetUserMedia );
this.navig.getUserMedia({video: true, audio: true}, (stream) => {
this.videoElement.nativeElement.src = window.URL.createObjectURL(stream);
this.videoElement.nativeElement.play();
}, (error) => console.warn('video error' + error))
Run Code Online (Sandbox Code Playgroud)
所以我想要捕获屏幕的流对象。那可能吗?
我在互联网上找到了这个,但这给我带来了一些错误......
navigator.mediaDevices.getDisplayMedia({ video: true })
.then(stream => {
// we have a stream, attach it to a feedback video element
videoElement.srcObject = stream;
}, error => {
console.log("Unable to acquire screen capture", error);
});
Run Code Online (Sandbox Code Playgroud)
2019年更新:是的,这是可能的。使用getDisplayMedia适用于 Chrome、Firefox 和 Safari
let displayMediaOptions = {video: true, audio: false};
navigator.mediaDevices.getDisplayMedia(displayMediaOptions)
.then(function(stream){
video_el.srcObject = stream;
})
Run Code Online (Sandbox Code Playgroud)
工作演示位于:thescreenshare.com
| 归档时间: |
|
| 查看次数: |
2259 次 |
| 最近记录: |