我的JS有以下内容:
var displayMediaOptions = {
video: {
cursor: "always",
height: 300,
width: 300
},
audio: false
}
var configuration = {
"iceServers": [{ "url": "stun:stun2.1.google.com:19302" }]
};
theConn = new RTCPeerConnection(configuration);
const theVideo = document.getElementById('theVideo');
theStream = await navigator.mediaDevices.getDisplayMedia(
displayMediaOptions,
function(stream) {
stream.getTracks().forEach(t=>theConn.addTrack(t));
},
function(err) {
alert("Not stream found");
});
当我运行这个,和Chrome弹出列表的可选择选项卡出现,它不显示调用选项卡。
您可以使用selfBrowserSurface
来包含当前选项卡。
const stream = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true,
selfBrowserSurface: "include",
});
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia