56 lines
2.0 KiB
HTML
56 lines
2.0 KiB
HTML
<html>
|
|
<head>
|
|
<!-- Need to include jQuery! -->
|
|
<link rel="stylesheet" type="text/css" href="reset.css">
|
|
<link rel="stylesheet" type="text/css" href="index.css">
|
|
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.1/howler.min.js" type="text/javascript"></script>
|
|
|
|
<script>
|
|
var audioPlayer = null;
|
|
// Listen for NUI Messages.
|
|
window.addEventListener('message', function(event) {
|
|
// Check for playSound transaction
|
|
if (event.data.Type === "playSound") {
|
|
if(event.data.File === 'none'){
|
|
if (audioPlayer != null) {
|
|
audioPlayer.pause();
|
|
audioPlayer = null;
|
|
}
|
|
}else {
|
|
/*if (audioPlayer != null) {
|
|
if(event.data.File != oldSound) {
|
|
audioPlayer.pause();
|
|
audioPlayer = new Howl({src: ["./sounds/" + event.data.File + ".ogg"]});
|
|
audioPlayer.volume(event.data.Volume);
|
|
audioPlayer.loop(true);
|
|
audioPlayer.play();
|
|
}
|
|
}else {*/
|
|
if (audioPlayer != null) {
|
|
audioPlayer.pause();
|
|
audioPlayer = null;
|
|
}
|
|
try{
|
|
audioPlayer = new Howl({src: ["./" + event.data.File + ".ogg"]});
|
|
audioPlayer.volume(event.data.Volume);
|
|
audioPlayer.play();
|
|
}catch(err){
|
|
$.post('http://soundbarrier/msg', JSON.stringify({
|
|
text: err.message
|
|
}));
|
|
}
|
|
//}
|
|
}
|
|
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
</head>
|
|
</html>
|