-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (61 loc) · 1.93 KB
/
index.html
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
69
70
71
72
73
<script>
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
"autoplay": "on",
"splashScreen": false,
"unmuteOverlay": "hidden",
};
function resizePlayer(player, aspectWidth, aspectHeight) {
const containerHeight = window.innerHeight;
const calculatedWidth = (containerHeight / aspectHeight) * aspectWidth;
player.style.height = "100%";
player.style.width = `${calculatedWidth}px`;
if (calculatedWidth > window.innerWidth) {
player.style.width = "100%";
player.style.height = `${(window.innerWidth / aspectWidth) * aspectHeight}px`;
}
}
window.addEventListener("load", (event) => {
const ruffle = window.RufflePlayer.newest();
const player = ruffle.createPlayer();
const container = document.getElementById("container");
container.appendChild(player);
const urlParams = new URLSearchParams(window.location.search);
const swfUrl = urlParams.get('url');
const aspectRatio = urlParams.get('aspect');
let aspectWidth = 4;
let aspectHeight = 3;
if (aspectRatio) {
const [width, height] = aspectRatio.split(':').map(Number);
if (!isNaN(width) && !isNaN(height)) {
aspectWidth = width;
aspectHeight = height;
}
}
if (swfUrl) {
player.load(swfUrl);
} else {
player.load("https://raw.githubusercontent.com/CodingKitten-YT/FlashEmbed/main/files/KittenGamez.swf");
}
resizePlayer(player, aspectWidth, aspectHeight);
window.addEventListener('resize', () => {
resizePlayer(player, aspectWidth, aspectHeight);
});
});
</script>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
<div id="container" style="height:100vh;"></div>
<style>
body {
margin: 0;
background-color: black;
}
#container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
overflow: hidden;
}
</style>