Skip to content

Commit bd72522

Browse files
committed
Added generic screensharing method
1 parent ce426f1 commit bd72522

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

docs/advanced-features/screen-share.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,29 @@ To share your screen instead of your webcam, the process is exactly the same as
1818

1919
```javascript
2020
var OV = new OpenVidu();
21-
var publisher = OV.initPublisher("html-element-id", { videoSource: "screen" });
21+
var sessionScreen = OV.initSession();
22+
getToken((token) => {
23+
sessionScreen.connect(token).then(() => {
24+
var publisher = OV.initPublisher("html-element-id", { videoSource: "screen" });
25+
26+
publisher.once('accessAllowed', (event) => {
27+
publisher.stream.getMediaStream().getVideoTracks()[0].addEventListener('ended', () => {
28+
console.log('User pressed the "Stop sharing" button');
29+
});
30+
sessionScreen.publish(publisher);
31+
32+
});
33+
34+
publisher.once('accessDenied', (event) => {
35+
console.warn('ScreenShare: Access Denied');
36+
});
37+
38+
}).catch((error => {
39+
console.warn('There was an error connecting to the session:', error.code, error.message);
40+
41+
}));
42+
}
43+
2244
```
2345
2446
### Chrome <72 and Opera (based on Chrome <72)

0 commit comments

Comments
 (0)