content/hifi-content/caitlyn/scratch/eventBridgeTest/unityWebBridge.html
2022-02-13 22:19:19 +01:00

78 lines
No EOL
3.4 KiB
HTML

<!DOCTYPE html>
<!-- saved from url=(0062)https://s3.amazonaws.com/hifi-public/tony/webBridgeTest.html?2 -->
<html lang="en" class="ui-mobile"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!--<base href="https://s3.amazonaws.com/hifi-public/tony/webBridgeTest.html?2">--><base href="."><link rel="stylesheet" href="./webBridgeTest_files/jquery.mobile-1.4.5.min.css">
<script src="./webBridgeTest_files/jquery-1.11.1.min.js.download"></script>
<script src="./webBridgeTest_files/jquery.mobile-1.4.5.min.js.download"></script>
<script>
$(document).ready(function () {
// hook up a handler for events that come from hifi.
EventBridge.scriptEventReceived.connect(function (msg) { // GET MESSAGES FROM HIFI
console.log("WEB: recv script event = " + JSON.stringify(msg));
if (msg === "button-1-done") { // Send a message to Unity that it was successfully played
// re-enable the button now that the audio is complete
$("#button-1").removeClass("ui-disabled"); // Replace with a message for Unity
} else if (msg === "button-2-done") {
// re-enable the button now that the audio is complete
$("#button-2").removeClass("ui-disabled");
}
});
// hook up a click handler for button-1
$("#button-1").click(function () { // SEND MESSAGES TO HIGH FIDELITY
// OK so it looks like this function is maybe evaluated? I still don't understand where eventbridge is gcreated or the emitWebEvent thing lives.
console.log("WEB: emit web event = " + JSON.stringify("button-1-play"));
// disable the button until we receive a done message.
$("#button-1").addClass("ui-disabled");
// send a play event to hifi
EventBridge.emitWebEvent("button-1-play"); // WHENCE DO EMIT WEB EVENT COME?
});
// hook up a click handler for button-2
$("#button-2").click(function () {
console.log("WEB: emit web event = " + JSON.stringify("button-2-play"));
// disable the button until we receive a done message.
$("#button-2").addClass("ui-disabled");
// send a play event to hifi
EventBridge.emitWebEvent("button-2-play");
});
});
</script>
<!--
<div data-role="page" id="page1">
<div data-role="header" data-position="fixed">
<h1>Soundboard</h1>
</div>
<div data-role="content">
<div data-role="controlgroup">
<a data-role="button" id="button-1">Button</a>
<a data-role="button" id="button-2">Button</a>
<a data-role="button" id="button-3">Button</a>
</div>
</div>
</div>
-->
<!--
<title></title></head><body class="ui-mobile-viewport ui-overlay-a"><div data-role="page" data-url="/hifi-public/tony/webBridgeTest.html?2" tabindex="0" class="ui-page ui-page-theme-a ui-page-active" style="min-height: 901px;">
<div style="margin:10px">
<button id="button-1" class="ui-btn ui-corner-all">Hiiya</button>
<button id="button-2" class="ui-btn ui-corner-all">My Wife!</button>
<button id="button-3" class="ui-btn ui-corner-all">Hello 1</button>
<button id="button-4" class="ui-btn ui-corner-all">Hello 2</button>
</div>
-->
</div><div class="ui-loader ui-corner-all ui-body-a ui-loader-default"><span class="ui-icon-loading"></span><h1>loading</h1></div></body></html>