Javascript + HTML
Code template
<!DOCTYPE html>
<html>
<head>
<title>Arcware Pixel Streaming WebSDK</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000;
font-family: system-ui;
}
#video-container {
width: 100vw;
height: 100vh;
position: relative;
}
/* Simple loader */
#loader {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
background: black;
z-index: 5;
}
.button-interaction {
position: absolute;
width: 200px;
right: 100px;
bottom: 20px;
z-index: 10;
}
</style>
<script type="module">
import { ArcwareInit } from "https://unpkg.com/@arcware-cloud/pixelstreaming-websdk@1.4.11/index.mjs";
let Application;
const { Application: ArcwareApplication } = ArcwareInit(
{
shareId: "share-d2477d89-0548-4785-9b9f-149071fb4fe3"
},
{
initialSettings: {
StartVideoMuted: true,
AutoConnect: true,
AutoPlayVideo: true
},
settings: {
infoButton: true,
micButton: true,
audioButton: true,
fullscreenButton: true,
settingsButton: true,
connectionStrengthIcon: true
}
}
);
Application = ArcwareApplication;
Application.getApplicationResponse((response) => {
console.log("ApplicationResponse", response);
});
window.addEventListener("DOMContentLoaded", () => {
const container = document.getElementById("video-container");
const loader = document.getElementById("loader");
// Wait until rootElement is ready
const waitForRoot = setInterval(() => {
if (Application?.rootElement instanceof Node) {
container.appendChild(Application.rootElement);
// remove loader once video is ready
loader.style.display = "none";
clearInterval(waitForRoot);
}
}, 50);
});
// Expose command sender
window.handleSendCommand = function (command) {
if (Application) {
Application.emitUIInteraction(command);
}
};
</script>
</head>
<body>
<div id="video-container">
<div id="loader">Loading Pixel Stream...</div>
</div>
<button
class="button-interaction"
onclick="handleSendCommand({ test: 'Send command' })"
>
Emit command to Unreal
</button>
</body>
</html>What this example does
Notes
Last updated