CreateSound: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 3: Line 3:
{{FuncDescription|Plays a local audio file or over http. Also supports playing .pls network streams.}}
{{FuncDescription|Plays a local audio file or over http. Also supports playing .pls network streams.}}


{{FuncSyntax|CreateSound(SoundFile)}}
{{FuncSyntax|CreateSound(SoundFile [, bLooping])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|SoundFile|The path to the file to play. Or a HTTP network stream or file.}}
{{FuncParam|SoundFile|The path to the file to play. Or a HTTP network stream or file.}}
{{FuncParamOptional|bLooping|Whether this sound should loop. Default: false.}}


{{FuncReturnValue|Returns the sound identifier. Returns '''false''' on error. Once the playback has finished the sound identifier will be destroyed automatically.}}
{{FuncReturnValue|Returns the sound identifier. Returns '''false''' on error. Once the playback has finished the sound identifier will be destroyed automatically.}}
Line 12: Line 13:
== Example ==
== Example ==
<syntaxhighlight lang="Lua">
<syntaxhighlight lang="Lua">
CreateSound("link")
-- Load sound from some package
CreateSound("package/sounds/mysound.mp3")
-- Load sound from current package
CreateSound("sounds/mysound.mp3")
</syntaxhighlight>
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{SoundFunctions}}
{{SoundFunctions}}

Revision as of 13:56, 14 August 2020

CreateSound

Type: Function
Context: Client
Introduced: v1.0

Description

Plays a local audio file or over http. Also supports playing .pls network streams.

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("package/sounds/mysound.mp3")
-- Load sound from current package
CreateSound("sounds/mysound.mp3")

See also