forked from hibas123/ScreenSharingThing
Compare commits
2 Commits
4840394627
...
5c47882b19
Author | SHA1 | Date | |
---|---|---|---|
|
5c47882b19 | ||
|
ec4c4dcb06 |
7
public/css/bootstrap.min.css
vendored
Normal file
7
public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -6,22 +6,21 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<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, initial-scale=1.0">
|
||||||
<title>SimpleStream</title>
|
<title>SimpleStream</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
<!-- //asset self hosting for non internet environments
|
||||||
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
//TODO: improve this later with correct tools like bundeling
|
||||||
<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>
|
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
|
<script src="./lib/jquery.min.js"></script>
|
||||||
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
|
<script src="./lib/bootstrap.bundle.min.js"></script>
|
||||||
crossorigin="anonymous"></script>
|
<script src="./lib/peerjs.min.js"></script>
|
||||||
<script src="https://unpkg.com/peerjs@1.3.1"></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row ">
|
||||||
<div class="col-md-12">
|
<div class="col-md-auto">
|
||||||
<h1>SimpleStream</h1>
|
<h1>SimpleStream</h1>
|
||||||
<h2>Your ID: <span id="streamId"></span></h2>
|
<h2>Your ID: <span id="streamId"></span></h2>
|
||||||
<div id="streamURLCont">
|
<div id="streamURLCont">
|
||||||
@ -33,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<video id="localVideo" style="width: 100%" controls></video>
|
<video id="localVideo" style="width: 100%; height: 100%;" controls></video>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
7
public/lib/bootstrap.bundle.min.js
vendored
Normal file
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
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
70
public/lib/peerjs.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -59,9 +59,12 @@ sf.streamId_text = "Loading...";
|
|||||||
sf.streamURL_text = "Loading...";
|
sf.streamURL_text = "Loading...";
|
||||||
|
|
||||||
let connectToId = new URL(window.location.href).searchParams.get("id");
|
let connectToId = new URL(window.location.href).searchParams.get("id");
|
||||||
|
let ownId = new URL(window.location.href).searchParams.get("own_id")
|
||||||
|
|
||||||
let bitrate = new URL(window.location.href).searchParams.get("br") || 50000;
|
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) {
|
if (connectToId) {
|
||||||
sf.streamURLCont_style = "display:none";
|
sf.streamURLCont_style = "display:none";
|
||||||
sf.connectToCont_style = "display:block";
|
sf.connectToCont_style = "display:block";
|
||||||
@ -71,11 +74,23 @@ if (connectToId) {
|
|||||||
sf.connectToCont_style = "display:none";
|
sf.connectToCont_style = "display:none";
|
||||||
}
|
}
|
||||||
|
|
||||||
var peer = new Peer({
|
if (ownId) {
|
||||||
host: window.location.hostname,
|
var peer = new Peer(ownId, {
|
||||||
port: window.location.port,
|
host: window.location.hostname,
|
||||||
path: "/peerjs",
|
port: window.location.port,
|
||||||
});
|
path: "/peerjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var peer = new Peer({
|
||||||
|
host: window.location.hostname,
|
||||||
|
port: window.location.port,
|
||||||
|
path: "/peerjs",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function bitrateTransform(sdp) {
|
function bitrateTransform(sdp) {
|
||||||
var arr = sdp.split("\r\n");
|
var arr = sdp.split("\r\n");
|
||||||
@ -101,7 +116,8 @@ let currentStream = undefined;
|
|||||||
peer.on("open", (id) => {
|
peer.on("open", (id) => {
|
||||||
console.log("ID", id);
|
console.log("ID", id);
|
||||||
sf.streamId_text = 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);
|
url.searchParams.set("id", id);
|
||||||
sf.streamURL_text = url.href;
|
sf.streamURL_text = url.href;
|
||||||
sf.streamURL_href = url.href;
|
sf.streamURL_href = url.href;
|
||||||
@ -117,7 +133,7 @@ peer.on("open", (id) => {
|
|||||||
video: true,
|
video: true,
|
||||||
})
|
})
|
||||||
.then((stream) => {
|
.then((stream) => {
|
||||||
if(currentStream) {
|
if (currentStream) {
|
||||||
currentStream.getTracks().forEach(track => track.stop())
|
currentStream.getTracks().forEach(track => track.stop())
|
||||||
}
|
}
|
||||||
currentStream = stream;
|
currentStream = stream;
|
||||||
|
Loading…
Reference in New Issue
Block a user