-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.html
72 lines (61 loc) · 2.15 KB
/
player.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>swf File Player</title>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
</head>
<center>
<style>
.download {
background-color: white;
color: black;
text-decoration: none;
}
</style>
<body>
<h3>To use this website you choose an .swf file from your computer.</h3>
<h3>And then your .swf file will be run and you can play it.</h3>
<br>
<input type="file" id="file-input" accept=".swf">
<div id="swf-container"></div>
<script>
// Initialize Ruffle
const ruffle = window.RufflePlayer.newest();
const ruffleContainer = document.getElementById('swf-container');
// Handle file input
document.getElementById('file-input').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file && file.type === "application/x-shockwave-flash") {
const reader = new FileReader();
reader.onload = function(e) {
const arrayBuffer = e.target.result;
// Create a blob from the array buffer
const blob = new Blob([arrayBuffer], { type: "application/x-shockwave-flash" });
// Create a URL for the blob
const objectURL = URL.createObjectURL(blob);
// Clear previous content
ruffleContainer.innerHTML = '';
// Create and configure the Ruffle player instance
const rufflePlayer = ruffle.createPlayer();
ruffleContainer.appendChild(rufflePlayer);
// Load the SWF file
rufflePlayer.load(objectURL);
};
reader.readAsArrayBuffer(file);
} else {
alert("Please select a valid swf file.");
}
});
</script>
<br>
<br>
<br>
<br>
<br>
<br>
<button>
<a class="download" href="https://github.com/Joercat/swfarchive.git"><h3>Click here if you need an swf file.</h3></a>
</button>
</center>
</body>
</html>