Skip to content

Commit

Permalink
Set frame url to either localhost or github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyherre committed Jun 3, 2022
1 parent 9842340 commit 75cdf8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<a id="status"></a>
<iframe src="http://localhost:8001/frame.html" id="subframe" style="display: none;" allow="display-capture;camera"></iframe>
<iframe id="subframe" style="display: none;" allow="display-capture;camera"></iframe>
<input type="button" id="sendPort" onclick="sendPort()" value="send port"/>
<input type="button" id="startTrack" onclick="startTrack()" value="Start track"/>
<input type="button" id="transfer" onclick="transferTrack()" value="Transfer track"/>
Expand Down
6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ startTrackBtn.disabled = true;
let transferBtn = document.getElementById("transfer");
transferBtn.disabled = true;

const frameOrigin =
document.location.host == "localhost:8000" ? "http://localhost:8001" : "https://tonyherre.github.io/mst-transfer-sample";

document.getElementById("subframe").src = frameOrigin + "/frame.html";

function isTrackTransferSupported() {
let track = document.createElement("canvas").captureStream().getTracks()[0];
Expand All @@ -32,7 +36,7 @@ onload = () => {
function sendPort() {
sendPortBtn.disabled = true;
let frame = document.getElementById("subframe");
frame.contentWindow.postMessage({name:"port", port: channel.port2}, "http://localhost:8001", [channel.port2]);
frame.contentWindow.postMessage({name:"port", port: channel.port2}, frameOrigin, [channel.port2]);
startTrackBtn.disabled = false;
};

Expand Down

0 comments on commit 75cdf8a

Please sign in to comment.