The code below:
//start recording
The function startCapture () {
Return the navigator. MediaDevices. GetDisplayMedia (options). Then (stream=& gt; {
Tracks=stream. GetTracks ();
If (tracks [0]. Label. IndexOf (" screen ")===1) {
Layer. Confirm (' you refused to record screen request, will be logged out! '{
BTN: [' know ']//button
, cancel: function (index, layero) {
LocalStorage. The clear ();
SessionStorage. The clear ();
Location. A href="https://bbs.csdn.net/topics/login.html";
}
{}, function (index)
layer.close(index);
LocalStorage. The clear ();
SessionStorage. The clear ();
Location. A href="https://bbs.csdn.net/topics/login.html";
});
Return
}
RecordingScreen ();//start the time
//JTSB ();//to monitor mouse action
Let the mediaRecorder=new mediaRecorder (stream);
The mediaRecorder. Ondataavailable=function (blob) {
FlagTime +=1;
Var oReq=new XMLHttpRequest ();
OReq. Open (" POST ", huijuOptions BasicsBaseUrl + '/capture/newFile, true);
Var fd=new FormData ();
Fd. Append (" datas ", blob. Data);
Fd. Append (" fileName ", captureName);
OReq. Send (fd);
};
The mediaRecorder. Start (1000)
}). The catch (error=& gt; {
If (error. Name==="NotAllowedError") {
Layer. Confirm (' you do not choose full screen recording, will log out! '{
BTN: [' know ']//button
, cancel: function (index, layero) {
LocalStorage. The clear ();
SessionStorage. The clear ();
Location. A href="https://bbs.csdn.net/topics/login.html";
}
{}, function (index)
layer.close(index);
LocalStorage. The clear ();
SessionStorage. The clear ();
Location. A href="https://bbs.csdn.net/topics/login.html";
});
}
//the console. The error (error);
});
}
CodePudding user response:
Added the options
Var options={
Audio: false,
AspectRatio: 1.6,
//deviceId: "screen: 69733568:0,"
FrameRate: 20,
Height: 450,
ResizeMode: "crop - and - scale",
Width: 720,
Cursor: "always",
DisplaySurface: "monitor",
LogicalSurface: false
}
CodePudding user response:
Use the inside of the IP mediaDevices object does not existCodePudding user response: