openvidu-electron: update to fit docs

This commit is contained in:
pabloFuente 2019-06-05 14:05:07 +02:00
parent 00252652ea
commit e08195ea68
6 changed files with 3691 additions and 8 deletions

3679
openvidu-electron/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"productName": "openvidu-electron",
"version": "1.0.0",
"description": "OpenVidu Electron Tutorial",
"main": "src/index.js",
"main": "src/main.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",

View File

@ -30,20 +30,18 @@ function initPublisher() {
function joinSession() {
mySessionId = document.getElementById("sessionId").value;
session = openvidu.initSession();
session.on("streamCreated", function (event) {
session.subscribe(event.stream, "subscriber");
});
mySessionId = document.getElementById("sessionId").value;
getToken(mySessionId).then(token => {
session.connect(token)
.then(() => {
showSession();
if (!!publisher) {
session.publish(publisher);
}
session.publish(publisher);
})
.catch(error => {
console.log("There was an error connecting to the session:", error.code, error.message);

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>
<html>
<head>
@ -7,9 +8,11 @@
<link rel="styleSheet" href="style.css" type="text/css" media="screen">
<script src="openvidu-browser-2.10.0.js"></script>
<script src="axios.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<h1>OpenVidu Electron</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>
@ -22,8 +25,6 @@
document.write(process.versions.electron)
</script>
<script src="app.js"></script>
<div id="join">
<h1>Join a video session</h1>
<form onsubmit="initPublisher(); return false">

View File

@ -47,13 +47,16 @@
const ipcRenderer = require('electron').ipcRenderer;
// Call Electron API to list all available screens
desktopCapturer.getSources({
types: ['window', 'screen']
}).then(async sources => {
const list = document.getElementById("list-of-screens");
sources.forEach(source => {
// Add new element to the list with the thumbnail of the screen
var el = document.createElement("div");
el.onclick = () => {
// Style the new selected screen and store it as the current selection
htmlElements.forEach(e => {
e.style.border = "none";
e.style.background = "none";
@ -63,12 +66,14 @@
selectedElement = el;
document.getElementById("share-btn").disabled = false;
}
// Store the new source and the new created HTML element
availableScreens.push(source);
htmlElements.push(el);
var img = document.createElement("img");
var name = document.createElement("span");
img.src = source.thumbnail.toDataURL();
name.innerHTML = source.name;
// Append new elements to the template
el.appendChild(img);
el.appendChild(name);
list.appendChild(el);