Compare commits

...

3 Commits

Author SHA1 Message Date
498929d7b8 html pfusch 2022-03-29 13:26:29 +02:00
5c47882b19 added own_id param as statefull id for viewer 2022-03-29 10:51:48 +02:00
ec4c4dcb06 asset selfhosting 2022-03-29 10:50:15 +02:00
7 changed files with 164 additions and 26 deletions

7
public/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

24
public/css/mystyle.css Normal file
View File

@ -0,0 +1,24 @@
/* * {
box-sizing: border-box !important;
margin: 0 !important;
padding: 0 !important;
} */
/* #main {
position: fixed;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
}
*/
body {
margin: 0;
height: 100vh;
width: 100%;
/* overflow: hidden; */
}
video {
width: 100% !important;
height: auto !important;
background-color: black;
}

View File

@ -1,28 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, height= initial-scale=1.0">
<link rel="stylesheet" href="./css/mystyle.css">
<title>SimpleStream</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<script src="https://unpkg.com/peerjs@1.3.1"></script>
<!-- //asset self hosting for non internet environments
//TODO: improve this later with correct tools like bundeling
-->
<link href="./css/bootstrap.min.css" rel="stylesheet">
<script src="./lib/jquery.min.js"></script>
<script src="./lib/bootstrap.bundle.min.js"></script>
<script src="./lib/peerjs.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>SimpleStream</h1>
<div class="container-fluid vh-100">
<div class="row-fluid">
<div class="col-md-auto">
<h1>SimpleStream (Alpha)</h1>
<h2>Your ID: <span id="streamId"></span></h2>
<div id="streamURLCont">
<h2>Connect URL: <a id="streamURL"></a></h2>
@ -31,12 +28,13 @@
<h2>Connecting to: <span id="connectToID"></span></h2>
<button id="startStramBTN">Start Stream</button>
</div>
</div>
</div>
<video id="localVideo" autoplay muted></video>
</div>
<video id="localVideo" style="width: 100%" controls></video>
</div>
<!-- style="min-width: 100%; min-height: 100%;width: auto; height: auto; z-index: -100; background-color: black;" -->
<script src="main.mjs" type="module">
</script>

7
public/lib/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
public/lib/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

70
public/lib/peerjs.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -57,11 +57,16 @@ let sf = simpleFramwork();
sf.streamId_text = "Loading...";
sf.streamURL_text = "Loading...";
sf.localVideo.enableAutosize = true;
let connectToId = new URL(window.location.href).searchParams.get("id");
let ownId = new URL(window.location.href).searchParams.get("own_id");
let autoFullscreen = new URL(window.location.href).searchParams.get("auto_fullscreen");
let bitrate = new URL(window.location.href).searchParams.get("br") || 50000;
//Connect to ID means: Iam the screensharer now.
//no ID Specified = Iam the Viewer
if (connectToId) {
sf.streamURLCont_style = "display:none";
sf.connectToCont_style = "display:block";
@ -71,11 +76,30 @@ if (connectToId) {
sf.connectToCont_style = "display:none";
}
var peer = new Peer({
host: window.location.hostname,
port: window.location.port,
path: "/peerjs",
});
if (ownId) {
var peer = new Peer(ownId, {
host: window.location.hostname,
port: window.location.port,
path: "/peerjs",
});
} else {
var peer = new Peer({
host: window.location.hostname,
port: window.location.port,
path: "/peerjs",
});
}
function fullscreenHandler(element, fullscreensetting) {
//main.mjs: 98 Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
//if (fullscreensetting) {
let res = element.requestFullscreen();
console.log(res);
//}
}
function bitrateTransform(sdp) {
var arr = sdp.split("\r\n");
@ -101,7 +125,8 @@ let currentStream = undefined;
peer.on("open", (id) => {
console.log("ID", id);
sf.streamId_text = id;
let url = new URL(window.location.href);
//clearing the params from the url
let url = new URL(window.location.href.split('?')[0]);
url.searchParams.set("id", id);
sf.streamURL_text = url.href;
sf.streamURL_href = url.href;
@ -117,7 +142,7 @@ peer.on("open", (id) => {
video: true,
})
.then((stream) => {
if(currentStream) {
if (currentStream) {
currentStream.getTracks().forEach(track => track.stop())
}
currentStream = stream;
@ -154,6 +179,11 @@ peer.on("call", (call) => {
console.log("stream", remoteStream);
let v = sf.localVideo;
v.srcObject = remoteStream;
//fullscreenHandler(v, autoFullscreen);
v.muted = true;
v.autoplay = true;
//because of https://developer.mozilla.org/de/docs/Web/HTML/Element/video
//because of https://developer.chrome.com/blog/autoplay/ (autoplay / play not possible with sound enabled)
v.play();
});
});