<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingTutorials%2FCustomAudio</id>
	<title>ScriptingTutorials/CustomAudio - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingTutorials%2FCustomAudio"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/CustomAudio&amp;action=history"/>
	<updated>2026-04-29T08:02:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/CustomAudio&amp;diff=10372&amp;oldid=prev</id>
		<title>Vortrex: Created page with &quot;{{DISPLAYTITLE:Scripting Tutorial: Custom Audio}}  == What is it? == GTA Connected provides scripting functions to play custom audio sounds in-game. These are &#039;&#039;&#039;not&#039;&#039;&#039; replac...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/CustomAudio&amp;diff=10372&amp;oldid=prev"/>
		<updated>2022-08-28T10:32:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{DISPLAYTITLE:Scripting Tutorial: Custom Audio}}  == What is it? == GTA Connected provides scripting functions to play custom audio sounds in-game. These are &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; replac...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Scripting Tutorial: Custom Audio}}&lt;br /&gt;
&lt;br /&gt;
== What is it? ==&lt;br /&gt;
GTA Connected provides scripting functions to play custom audio sounds in-game. These are &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; replacements of in-game sounds, but instead just extra sounds and audio you can play whenever.&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
Create the sound first. This can be done one of two ways: file or internet stream. See the audio file or internet stream sections below for information on how to set them up.&lt;br /&gt;
&lt;br /&gt;
== Using audio file ==&lt;br /&gt;
The audio file option is used with [[audio.createSound|audio.createSound]]. You&amp;#039;ll need to add the audio file to [[Resources|meta.xml]] so the client caches it.&lt;br /&gt;
Example:&lt;br /&gt;
{{JSCode|1=&lt;br /&gt;
let audioObject = null;&lt;br /&gt;
let audioFile = openFile(&amp;quot;audio-file.mp3&amp;quot;);&lt;br /&gt;
if (audioFile) {&lt;br /&gt;
    audioObject = audio.createSound(audioFile);&lt;br /&gt;
    audioFile.close();&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Using internet stream ==&lt;br /&gt;
The internet stream option is used with [[audio.createSoundFromURL|audio.createSoundFromURL]]. &lt;br /&gt;
Example:&lt;br /&gt;
{{JSCode|1=&lt;br /&gt;
let audioObject = audio.createSoundFromURL(&amp;quot;http://example.com/audio-file.mp3&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Next step ==&lt;br /&gt;
Using one of the two methods above, you now have a sound object you can use with [[sound.play|sound.play]], [[sound.stop|sound.stop]], [[sound.position|sound.position]] and [[sound.volume|sound.volume]]&lt;br /&gt;
&lt;br /&gt;
== Important notes ==&lt;br /&gt;
* For the audio file option, you can use an [[OnResourceReady|OnResourceReady]] event handler to detect when all the client files are finished downloading. &amp;#039;&amp;#039;&amp;#039;If you try to load the audio file before the client files are downloaded, it will fail.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* The [[sound.position|sound.position]] property is a seek position, not a game world position. It indicates where in the track the audio playback is currently&lt;br /&gt;
* The [[sound.volume|sound.volume]] range is 0 (mute) to 1 (full volume). If you want to use whole number percentage (0-100, like 50 for half volume) you can divide the number by 100 to get the correct value.&lt;/div&gt;</summary>
		<author><name>Vortrex</name></author>
	</entry>
</feed>