Home > front end >  GetDisplayMedia () in the use of IP access cannot be used.
GetDisplayMedia () in the use of IP access cannot be used.

Time:09-21

When I use localhost local access can be used to record the screen features (for example: localhost/target/index. The HTML), but when I access by IP address (for example: 172.16.2.222/target/index. The HTML) would be an error: getDisplayMedia 'of undefined, someone met you
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 exist

CodePudding user response:

refer to the second floor jio can reply:
mediaDevices object using IP inside there is no

You say is what meaning, I didn't quite understand

CodePudding user response:

When using the IP address in the navigator mediaDevices object does not exist

CodePudding user response:

references 4 floor jio can reply:
when using IP address in the navigator mediaDevices object doesn't exist

Thanks, solved, the reason is the navigator. MediaDevices support only localhost, HTTPS, file://these three kinds of environment, need to configure the HTTP
  • Related