-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmml-screen.html
More file actions
68 lines (59 loc) · 1.9 KB
/
Copy pathmml-screen.html
File metadata and controls
68 lines (59 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<m-group>
<!-- GAME BOY MODEL -->
<m-model
src="https://raw.githubusercontent.com/jdunk4/ARCADE1/main/MODELS/mario_land_buttons_wide.glb"
sx="0.28" sy="0.4" sz="0.4"
y="2.282" z="-0.064">
</m-model>
<!-- LIVE STREAM SCREEN -->
<m-image id="screen"
src="https://raw.githubusercontent.com/jdunk4/ARCADE1/main/SCREEN/NSMW1-12MagicOrbs.png"
width="2.2" height="2.0"
x="0" y="2.359" z="0.241">
</m-image>
<m-label id="status-label" content=""
y="0.3" z="0.3" width="3" height="0.2"
font-size="11" color="#ffff00" alignment="center">
</m-label>
<script>
(function(root) {
var SERVER = "wss://arcade2-production.up.railway.app";
var PREVIEW = "https://raw.githubusercontent.com/jdunk4/ARCADE1/main/SCREEN/NSMW1-12MagicOrbs.png";
function set(id, a, v) {
var e = root.querySelector("#" + id);
if (e) e.setAttribute(a, v);
}
function handle(data) {
try {
var f = JSON.parse(data);
if (f.type === "status") {
set("status-label", "content", f.message || "");
if (f.message === "Stream ended") set("screen", "src", PREVIEW);
return;
}
if (f.image) {
set("screen", "src", f.image);
set("status-label", "content", "");
}
} catch(e) {}
}
function connect() {
var s = new WebSocket(SERVER + "?mode=view&channel=snes-live");
s.onmessage = function(m) {
var d = m.data;
if (d && typeof d.text === "function") {
d.text().then(handle).catch(function() {});
return;
}
handle(d);
};
s.onclose = function() {
set("status-label", "content", "Reconnecting...");
setTimeout(connect, 3000);
};
s.onerror = function() {};
}
setTimeout(connect, 500);
})(document.currentScript ? document.currentScript.closest("m-group") : document);
</script>
</m-group>