Scripts/resources/[standalone]/interact-sound/client/html/index.html

26 lines
926 B
HTML
Raw Normal View History

2024-12-29 20:02:20 +00:00
<html>
<head>
<!-- Need to include jQuery! -->
<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.transactionType == "playSound") {
if (audioPlayer != null) {
audioPlayer.pause();
}
audioPlayer = new Howl({src: ["./sounds/" + event.data.transactionFile + ".ogg"]});
audioPlayer.volume(event.data.transactionVolume);
audioPlayer.play();
}
});
</script>
</head>
</html>