uranium / flash.html
hihihi934's picture
Update flash.html
ad86c22 verified
Raw
History Blame Contribute Delete
2.87 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ruffle flash player</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
height: 100%;
background: #000;
overflow: hidden;
font-family: Arial, sans-serif;
}
#container {
width: 100%;
height: 100%;
}
#message {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding: 20px;
background: rgba(0, 0, 0, 0.9);
color: #fff;
text-align: center;
z-index: 100;
display: none;
}
#message.error {
background: rgba(180, 0, 0, 0.95);
}
</style>
</head>
<body>
<div id="message"></div>
<div id="container"></div>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
<script>
function getUrlParameter(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);
}
function showMessage(text, isError = false) {
const msg = document.getElementById('message');
msg.textContent = text;
msg.classList.toggle('error', isError);
msg.style.display = 'block';
}
window.addEventListener('load', async () => {
const swfUrl = getUrlParameter('url');
if (!swfUrl) {
showMessage("NO!!!", true);
return;
}
// make url absolute if needed
let fullUrl = swfUrl;
if (!swfUrl.startsWith('http://') && !swfUrl.startsWith('https://')) {
fullUrl = new URL(swfUrl, window.location.origin).href;
}
try {
// new ruffle api
window.RufflePlayer = window.RufflePlayer || {};
const ruffle = window.RufflePlayer.newest();
const player = ruffle.createPlayer();
const container = document.getElementById('container');
container.appendChild(player);
// make it fill the whole screen
player.style.width = "100%";
player.style.height = "100%";
await player.load({
url: fullUrl,
autoplay: true,
quality: "high",
letterbox: "on",
backgroundColor: "#000000"
});
} catch (err) {
console.error(err);
showMessage(`NO!!!\nactually because${err.message}`, true);
}
});
</script>
</body>
</html>