mirror of
https://github.com/eliasstepanik/vdo.ninja.git
synced 2026-01-11 13:48:38 +00:00
667 lines
26 KiB
HTML
667 lines
26 KiB
HTML
<html>
|
|
<head>
|
|
<title>IFRAME Example</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
|
<style>
|
|
body{
|
|
padding:0;
|
|
margin:0;
|
|
background-color: rgb(222,242,253);
|
|
}
|
|
iframe {
|
|
border:0;
|
|
margin:0;
|
|
padding:0;
|
|
display:block;
|
|
margin:10px;
|
|
width:100%;
|
|
height:520px;
|
|
}
|
|
#viewlink {
|
|
width:400px;
|
|
}
|
|
#container {
|
|
display:block;
|
|
padding:0px;
|
|
}
|
|
input{
|
|
padding:5px;
|
|
margin:5px;
|
|
}
|
|
button{
|
|
padding:5px;
|
|
margin:5px;
|
|
}
|
|
</style>
|
|
<script>
|
|
|
|
function loadIframe(){ // this is pretty important if you want to avoid camera permission popup problems. You can also call it automatically via: <body onload=>loadIframe();"> , but don't call it before the page loads.
|
|
|
|
var iframe = document.createElement("iframe");
|
|
var iframeContainer = document.createElement("div");
|
|
var iframesrc = document.getElementById("viewlink").value;
|
|
iframe.allow = "autoplay;camera;microphone;fullscreen;picture-in-picture;display-capture;";
|
|
|
|
if (iframesrc==""){
|
|
iframesrc="./";
|
|
}
|
|
|
|
if (document.getElementById("clean").checked){
|
|
if (iframesrc.includes("?")){
|
|
iframesrc+='&';
|
|
} else {
|
|
iframesrc+='?';
|
|
}
|
|
iframesrc+="cleanoutput";
|
|
}
|
|
if (document.getElementById("transparent").checked){
|
|
if (iframesrc.includes("?")){
|
|
iframesrc+='&';
|
|
} else {
|
|
iframesrc+='?';
|
|
}
|
|
iframesrc+="transparent";
|
|
}
|
|
|
|
if (document.getElementById("hidemenu").checked){
|
|
if (iframesrc.includes("?")){
|
|
iframesrc+='&';
|
|
} else {
|
|
iframesrc+='?';
|
|
}
|
|
iframesrc+="hidemenu";
|
|
}
|
|
|
|
iframe.src = iframesrc;
|
|
|
|
iframeContainer.appendChild(iframe);
|
|
|
|
document.getElementById("container").appendChild(iframeContainer);
|
|
|
|
|
|
var h3 = document.createElement("h3");
|
|
h3.innerText = "The following commands are exclusive to the IFRAME API.";
|
|
iframeContainer.appendChild(h3);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Mute Speaker";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mute":true}, '*');}; // "speaker" also works in the same way.
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Un-Mute Speaker";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mute":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Toggle Speaker";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mute":"toggle"}, '*');}; // open to a better suggestion here.
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Mute Mic";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mic":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Un-Mute Mic";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mic":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Toggle Mic";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"mic":"toggle"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Mute Camera";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"camera":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Unmute Camera";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"camera":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Toggle Camera";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"camera":"toggle"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Disconnect";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"close":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "0 Bitrate";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"bitrate":0, "target": "*"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Low Bitrate";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"bitrate":30, "target": "*"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "High Bitrate";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"bitrate":5000, "target": "*"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Default Bitrate";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"bitrate":-1, "target": "*"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Reload";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"reload":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "50% Volume";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"volume":0.5}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "100% Volume";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"volume":1.0}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Pan Left";
|
|
button.title = "Requires &panning to be added to the view link";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"panning":0}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Pan right";
|
|
button.title = "Requires &panning to be added to the view link";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"panning":180}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Pan Center";
|
|
button.title = "Requires &panning to be added to the view link";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"panning":90}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Request Loudness Levels";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"getLoudness":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Stop Sending Loudness Levels";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"getLoudness":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Get detailed state (if Director)";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"getDetailedState":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Start Recording";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"record":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Stop Recording";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"record":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Say Hello";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"sendChat":"Hello!"}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Send Keyframe";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"keyframe":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Insert Style Sheet";
|
|
var stylesheet = "#main { zoom: 0.5;} video {float: left; margin: 0; padding: 0; } #info {display:none;}";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"style":stylesheet}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "get StreamIDs and labels";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"getStreamIDs":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "get media device list";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"getDeviceList":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Start AutoMixer";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"automixer":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Stop AutoMixer";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"automixer":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "ENABLE TALLY LIGHT";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"sceneState":true}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "STOP TALLY LIGHT";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"sceneState":false}, '*');};
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Add Target Video";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"target":"*", "add":true, "settings": {"style": "width:640px;height:360px;float:left;border:10px solid red;display:block;"}}, '*');}; // target can be a stream ID or * for all.
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Remove Target Video";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"target":"*", "remove": true}, '*');}; // target can be a stream ID or * for all.
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "previewWebcam()";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"function":"previewWebcam"}, '*');}; // publishScreen
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Change to Camera #2";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"changeVideoDevice":2}, '*');}; // change text of add camera button
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Change to Microphone #4";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"changeAudioDevice":4}, '*');}; // change text of add camera button
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "eval('alert(\"DANGERUS\")'";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"function":"eval", "value":'alert(\"DANGERUS\")'}, '*');}; // publishScreen
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "Change Add Camera text";
|
|
button.onclick = function(){iframe.contentWindow.postMessage({"function":"changeHTML", "target":"add_camera", "value":"NEW CAMERA TEXT"}, '*');}; // change text of add camera button
|
|
iframeContainer.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "CLOSE IFRAME";
|
|
button.onclick = function(){iframeContainer.parentNode.removeChild(iframeContainer);};
|
|
iframeContainer.appendChild(button);
|
|
|
|
//////////// LISTEN FOR EVENTS
|
|
|
|
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
|
var eventer = window[eventMethod];
|
|
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
|
|
|
|
|
|
/// If you have a routing system setup, you could have just one global listener for all iframes instead.
|
|
|
|
eventer(messageEvent, function (e) {
|
|
if (e.source != iframe.contentWindow){return} // reject messages send from other iframes
|
|
|
|
if ("stats" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
console.log(e.data.stats);
|
|
|
|
|
|
var out = "<br />total_inbound_connections:"+e.data.stats.total_inbound_connections;
|
|
out += "<br />total_outbound_connections:"+e.data.stats.total_outbound_connections;
|
|
|
|
for (var streamID in e.data.stats.inbound_stats){
|
|
out += "<br /><br /><b>streamID:</b> "+streamID+"<br />";
|
|
out += printValues(e.data.stats.inbound_stats[streamID]);
|
|
}
|
|
|
|
outputWindow.innerHTML = out;
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
if ("gotChat" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.innerHTML = e.data.gotChat.msg;
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
if ("action" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.innerHTML = "child-page-action: "+e.data.action+"<br />";
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
|
|
if ("streamIDs" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.innerHTML = "child-page-action: streamIDs<br />";
|
|
for (var key in e.data.streamIDs) {
|
|
outputWindow.innerHTML += "streamID: " + key + ", label:"+e.data.streamIDs[key] + "\n";
|
|
}
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
if ("deviceList" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.innerHTML = "child-page-action: deviceList<br />";
|
|
for (var i = 0;i<e.data.deviceList.length;i++){
|
|
outputWindow.innerHTML += e.data.deviceList[i].label + "<br />";
|
|
}
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
|
|
if ("loudness" in e.data){
|
|
console.log(e.data);
|
|
if (document.getElementById("loudness")){
|
|
outputWindow = document.getElementById("loudness");
|
|
} else {
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
outputWindow.id = "loudness";
|
|
}
|
|
outputWindow.innerHTML = "child-page-action: loudness<br />";
|
|
for (var key in e.data.loudness) {
|
|
outputWindow.innerHTML += key + " Loudness: " + e.data.loudness[key] + "\n";
|
|
}
|
|
outputWindow.style.border="1px black";
|
|
}
|
|
|
|
if ("detailedState" in e.data){
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.innerHTML = "child-page-action: detailedState<br />"+JSON.stringify(e.data.detailedState)+"<br />";
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
}
|
|
|
|
if ("sensors" in e.data){
|
|
console.log(e.data);
|
|
if (document.getElementById("sensors")){
|
|
outputWindow = document.getElementById("sensors");
|
|
} else {
|
|
var outputWindow = document.createElement("div");
|
|
outputWindow.style.border="1px dotted black";
|
|
iframeContainer.appendChild(outputWindow);
|
|
outputWindow.id = "sensors";
|
|
}
|
|
outputWindow.innerHTML = "child-page-action: sensors<br /><br />";
|
|
|
|
for (var key in e.data.sensors.lin) {
|
|
outputWindow.innerHTML += key + " linear: " + e.data.sensors.lin[key] + "<br />";
|
|
}
|
|
for (var key in e.data.sensors.acc) {
|
|
outputWindow.innerHTML += key + " acceleration: " + e.data.sensors.acc[key] + "<br />";
|
|
}
|
|
for (var key in e.data.sensors.gyro) {
|
|
outputWindow.innerHTML += key + " gyro: " + e.data.sensors.gyro[key] + "<br />";
|
|
}
|
|
for (var key in e.data.sensors.mag) {
|
|
outputWindow.innerHTML += key + " magnet: " + e.data.sensors.mag[key] + "<br />";
|
|
}
|
|
outputWindow.style.border="1px black";
|
|
|
|
}
|
|
});
|
|
|
|
function loadSelfCommands(){
|
|
var commands = {}
|
|
commands.speaker = function(value){sendSelfCommand("speaker",value)}; // "speaker" also works in the same way
|
|
|
|
commands.mic = function(value){sendSelfCommand("mic",value)};
|
|
|
|
commands.camera = function(value){sendSelfCommand("camera",value)};
|
|
|
|
commands.bitrate = function(value){sendSelfCommand("bitrate",value)};
|
|
|
|
commands.volume = function(value){sendSelfCommand("volume",value)};
|
|
|
|
commands.record = function(value){sendSelfCommand("record",value)};
|
|
|
|
commands.sayHello = function(value){sendSelfCommand("sendChat","Hello")};
|
|
|
|
var target_self = document.body;
|
|
|
|
var hr = document.createElement("hr");
|
|
target_self.appendChild(hr);
|
|
|
|
var h3 = document.createElement("h3");
|
|
h3.innerText = "The following commands re-use the Companion.Ninja HTTP/WSS API, except you can send them via this Iframe interface.";
|
|
target_self.appendChild(h3);
|
|
|
|
var a = document.createElement("a");
|
|
a.innerText = "More details of the below IFRAME API details are here: https://github.com/steveseguin/Companion-Ninja#api-commands";
|
|
a.href = "https://github.com/steveseguin/Companion-Ninja#api-commands";
|
|
a.target = "_blank";
|
|
target_self.appendChild(a);
|
|
|
|
var hr = document.createElement("hr");
|
|
target_self.appendChild(hr);
|
|
|
|
|
|
for (var k in commands) {
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = k + ":<br />TRUE";
|
|
button.dataset.command = k;
|
|
button.onclick = function(){commands[this.dataset.command](true);}
|
|
target_self.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = k + ":<br />FALSE";
|
|
button.dataset.command = k;
|
|
button.onclick = function(){commands[this.dataset.command](false);}
|
|
target_self.appendChild(button);
|
|
|
|
if (k=="mic" || k=="camera" || k=="record" || k=="speaker"){
|
|
var button = document.createElement("button");
|
|
button.innerHTML = k + ":<br />TOGGLE";
|
|
button.dataset.command = k;
|
|
button.onclick = function(){commands[this.dataset.command]("toggle");}
|
|
target_self.appendChild(button);
|
|
}
|
|
|
|
} // list available commands to console
|
|
|
|
commands.reload = function(){sendSelfCommand("reload",true);};
|
|
|
|
commands.hangup = function(){sendSelfCommand("hangup",true);};
|
|
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = k + ":<br />TRUE";
|
|
button.onclick = function(){commands["reload"](true);}
|
|
target_self.appendChild(button);
|
|
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = k + ":<br />TRUE";
|
|
button.onclick = function(){commands["hangup"](true);}
|
|
target_self.appendChild(button);
|
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
function loadGuestCommands(guestid, streamID=false){ // this is the same as the Companion API, but can be issued to the IFRAME API
|
|
|
|
var container = document.createElement("div");
|
|
container.id = "guest_"+guestid+"_container";
|
|
document.body.appendChild(container);
|
|
|
|
var hr = document.createElement("hr");
|
|
container.appendChild(hr);
|
|
var h3 = document.createElement("h3");
|
|
if (streamID){
|
|
h3.innerHTML = "These target guest with the streamID: <i>"+guestid+ "</i> (if a director)";
|
|
} else {
|
|
h3.innerText = "These target the guest in slot "+guestid+ " (if you are director)";
|
|
}
|
|
container.appendChild(h3);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "transfer popup";
|
|
button.onclick = function(){sendGuestCommand(guestid, "forward");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "transfer to 'room321'";
|
|
button.onclick = function(){sendGuestCommand(guestid, "forward", 'room321');};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 1";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene");}; /// SCENE 1 or specify a custom scene name as a value
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "mute in scene";
|
|
button.onclick = function(){sendGuestCommand(guestid, "muteScene");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "mute everywhere";
|
|
button.onclick = function(){sendGuestCommand(guestid, "mic");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "hang up";
|
|
button.onclick = function(){sendGuestCommand(guestid, "hangup");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "solo chat";
|
|
button.onclick = function(){sendGuestCommand(guestid, "soloChat");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "remote speaker";
|
|
button.onclick = function(){sendGuestCommand(guestid, "speaker");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "remote display";
|
|
button.onclick = function(){sendGuestCommand(guestid, "display");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "rainbow puke fix";
|
|
button.onclick = function(){sendGuestCommand(guestid, "forceKeyframe");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "highlight";
|
|
button.onclick = function(){sendGuestCommand(guestid, "soloVideo");};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 2";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 2);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 3";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 3);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 4";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 4);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 5";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 5);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 6";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 6);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = " scene 7";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 7);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 8";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 8);};
|
|
container.appendChild(button);
|
|
|
|
var button = document.createElement("button");
|
|
button.innerHTML = "scene 'test'";
|
|
button.onclick = function(){sendGuestCommand(guestid, "addScene", 'test');}; // specifying a custom scene; it needs to be active for this to work..
|
|
container.appendChild(button);
|
|
|
|
|
|
var input = document.createElement("label");
|
|
input.innerHTML = "mic volume:";
|
|
container.appendChild(input);
|
|
var input = document.createElement("input");
|
|
input.type = "range";
|
|
input.title = "volume";
|
|
input.min = 0;
|
|
input.max = 200;
|
|
input.value = 100;
|
|
input.onchange = function(){sendGuestCommand(guestid, "volume", this.value);};
|
|
container.appendChild(input);
|
|
|
|
}
|
|
|
|
function sendGuestCommand(target, action, value=null){ //
|
|
iframe.contentWindow.postMessage({"target":target, "action":action, "value":value}, '*'); //
|
|
//sendMessage(JSON.stringify({"target":target, "action":action, "value":value})); // if using the Companion API..
|
|
}
|
|
|
|
function sendSelfCommand(action, value=null){
|
|
iframe.contentWindow.postMessage({"target":null, "action":action, "value":value}, '*');
|
|
//sendMessage(JSON.stringify({"target":target, "action":action, "value":value})); // if using the Companion API..
|
|
}
|
|
|
|
loadSelfCommands();
|
|
loadGuestCommands(1);
|
|
loadGuestCommands(2);
|
|
loadGuestCommands(3);
|
|
var randomGuest = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 10);
|
|
loadGuestCommands(randomGuest, true);
|
|
|
|
}
|
|
function printValues( obj) {
|
|
var out = "";
|
|
for (var key in obj) {
|
|
if (typeof obj[key] === "object") {
|
|
out +="<br />";
|
|
out += printValues(obj[key]);
|
|
} else {
|
|
out +="<b>"+key+"</b>: "+obj[key]+"<br />";
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<input placeholder="Enter an VDO.Ninja View URL here" id="viewlink" />
|
|
<button onclick="loadIframe();">ADD</button>
|
|
<input type="checkbox" id="clean" >Clean Output
|
|
<input type="checkbox" id="transparent">Transparent
|
|
<input type="checkbox" id="hidemenu">Hide Menu
|
|
<div id="container">
|
|
|
|
</div>
|
|
</body>
|
|
</html> |