Garry's Mod Wiki

Revision Difference

sound.PlayURL#512917

<function name="PlayURL" parent="sound" type="libraryfunc">⤶ <description>⤶ Allows you to play external sound files, as well as online radio streams.⤶ You can find a list of all error codes [here](http://www.un4seen.com/doc/#bass/BASS_ErrorGetCode.html)⤶ ⤶ For offline file playback, see <page>sound.PlayFile</page>.⤶ ⤶ <bug issue="2296">Due to a bug with [BASS](http://www.un4seen.com/), AAC codec streams cannot be played in 3D mode.</bug>⤶ </description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="url" type="string">The URL of the sound to play</arg>⤶ <arg name="flags" type="string">Flags for the sound. Can be one or more of following, separated by a space (&quot; &quot;):&#xA;* 3d - Makes the sound 3D, so you can set its position&#xA;* mono - Forces the sound to have only one channel&#xA;* noplay - Forces the sound not to play as soon as this function is called&#xA;* noblock - Disables streaming in blocks. It is more resource-intensive, but it is required for &lt;page&gt;IGModAudioChannel:SetTime&lt;/page&gt;.&#xA;&#xA;&#xA;&#xA;&#xA;If you don&#x27;t want to use any of the above, you can just leave it as &quot;&quot;.</arg>⤶ <arg name="callback" type="function">Callback function that is called as soon as the the stream is loaded. It has next arguments:&#xA;&#xA;&#xA;&lt;page&gt;IGModAudioChannel&lt;/page&gt; soundchannel - The sound channel&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; errorID - ID of an error, if an error has occured&#xA;&#xA;&#xA;&lt;page&gt;string&lt;/page&gt; errorName - Name of an error, if an error has occured</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Example usage of the function.</description>⤶ <code>⤶ sound.PlayURL ( "URL", "3d", function( station )⤶ if ( IsValid( station ) ) then⤶ ⤶ station:SetPos( LocalPlayer():GetPos() )⤶ ⤶ station:Play()⤶ ⤶ else⤶ ⤶ LocalPlayer():ChatPrint( "Invalid URL!" )⤶ ⤶ end⤶ end )⤶ </code>⤶ ⤶ </example>