CreateSound: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|CreateSound(SoundFile [, bLoop])}} {{FuncParameters}} {{FuncParam|SoundFile |__EDIT_ME__}} {{FuncP..." |
No edit summary |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Plays a local audio file or over http. Also supports playing .pls network streams. | ||
{{FuncSyntax|CreateSound(SoundFile [, | See [[packages]] what audio file types are supported.}} | ||
{{FuncSyntax|CreateSound(SoundFile [, bLooping])}} | |||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|SoundFile | | {{FuncParam|SoundFile|The path to the file to play. Or a HTTP network stream or file.}} | ||
{{FuncParamOptional| | {{FuncParamOptional|bLooping|Whether this sound should loop. Default: false.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the sound identifier. Returns '''false''' on error. Once the playback has finished the sound identifier will be destroyed automatically.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
-- Load sound from some package | |||
CreateSound("testpackage/sounds/mysound.mp3") | |||
-- Load sound from current package | |||
CreateSound("sounds/mysound.mp3") | |||
-- Play HTTP network stream | |||
CreateSound("http://us4.internet-radio.com:8258/listen.pls&t=.pls") | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{SoundFunctions}} |
Latest revision as of 18:50, 14 December 2020
Description
Plays a local audio file or over http. Also supports playing .pls network streams.
See packages what audio file types are supported.
Syntax
CreateSound(SoundFile [, bLooping])
Parameters
- SoundFile
The path to the file to play. Or a HTTP network stream or file. - bLooping (optional)
Whether this sound should loop. Default: false.
Return Value
- Returns the sound identifier. Returns false on error. Once the playback has finished the sound identifier will be destroyed automatically.
Example
-- Load sound from some package
CreateSound("testpackage/sounds/mysound.mp3")
-- Load sound from current package
CreateSound("sounds/mysound.mp3")
-- Play HTTP network stream
CreateSound("http://us4.internet-radio.com:8258/listen.pls&t=.pls")