1
0
Fork 0
forked from Simnation/Main
Main/resources/[housing]/renzu_motels/data/script.js

32 lines
870 B
JavaScript
Raw Normal View History

2025-07-10 13:19:26 +02:00
function playsound(table) {
var file = table['file']
var volume = table['volume']
var audioPlayer = null;
if (audioPlayer != null) {
audioPlayer.pause();
}
if (volume == undefined) {
volume = 0.2
}
audioPlayer = new Audio("./audio/" + file + ".ogg");
audioPlayer.volume = volume;
audioPlayer.play();
}
window.addEventListener('message', function(event) {
var data = event.data;
if (event.data.type == 'playsound') {
playsound(event.data.content)
}
if (event.data.type == 'door') {
document.getElementById('door').innerHTML = `
<video autoplay id="myVideo">
<source src="audio/door.mp4" type="video/mp4">
</video>
`
setTimeout(function() {
document.getElementById('door').innerHTML = ''
}, 7000)
}
});