From 67a7f37d2104042c541ef1a33d664557e1db3d1c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Thu, 30 Sep 2021 18:56:25 -0500 Subject: [PATCH] New internet radio streaming client script --- scripts/client/radio.js | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripts/client/radio.js diff --git a/scripts/client/radio.js b/scripts/client/radio.js new file mode 100644 index 00000000..d9b2c096 --- /dev/null +++ b/scripts/client/radio.js @@ -0,0 +1,45 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: radio.js +// DESC: Provides internet streaming radio functions and usage +// TYPE: Client (JavaScript) +// =========================================================================== + +function playStreamingRadio(url, loop, volume, element = false) { + if(url == "") { + if(streamingRadio != null) { + streamingRadio.stop(); + } + return true; + } + + if(streamingRadio != null) { + streamingRadio.stop(); + } + + streamingRadioVolume = volume; + + streamingRadio = audio.createSoundFromURL(url, loop); + streamingRadio.volume = volume/100; + streamingRadio.play(); +} + +// =========================================================================== + +function stopStreamingRadio() { + streamingRadio.stop(); + streamingRadio = null; +} + +// =========================================================================== + +function setStreamingRadioVolume(volume) { + if(streamingRadio != null) { + streamingRadioVolume = volume; + streamingRadio.volume = volume/100; + } +} + +// =========================================================================== \ No newline at end of file