Here's the scenario, I have 2 Urls, let's say
Url 1 - http://mydomain/teacher/dashboard
Url 2 - http://mydomain/students/workspace
In Url 1 is where the user can only share the screen and needs to be shared or broadcasted to the other url page which is Url 2 within the video element of that page. Is this possible? Currently, I'm using webRTC and signalR to do this task. At the moment, I got an error which is coming from this Url(http://mydomain/students/workspace) within the signalR on-listener function after it was invoked and the video element in the url(http://mydomain/students/workspace) page remains in black screen.
Error: A callback for the method 'clientsharedscreen' threw error 'TypeError: Failed to set the 'srcObject' property on 'HTMLMediaElement': The provided value is not of type '(MediaSourceHandle or MediaStream)'.
For more details here are some codes I used:
C# Hub:
// Live Screen Sharing...
public async Task ServerSharedScreen(int classCode, object share)
{
await Clients.Others.SendAsync("ClientSharedScreen", classCode, share);
}
HTML:
<div id="welcome-class-div3" class="col-md-12 col-lg-12 col-xl-12 col-sm-12 col-xs-12">
<video id="share-screen-container" autoplay playsinline muted></video>
</div>
JS with signalR:
$('#share-screen-btn').click(function () {
const options = { audio: true, video: true };
const displaySurface = 'default';
if (displaySurface !== 'default') {
options.video = { displaySurface };
}
navigator.mediaDevices.getDisplayMedia(options)
.then(handleSuccess, handleError);
});
function handleSuccess(stream) {
connection.invoke("ServerSharedScreen", clsCode, stream)
.catch(function (err) {
return console.error(err.toString());
});
}
// Screen-sharing...
connection.on("ClientSharedScreen", function (classCode2, stream) {
if (classCode2 == classCode) {
const video = document.querySelector('video');
video.srcObject = stream;
}
});
Please help share your thoughts if you know how to resolve this type of problem. Thank u.