Sound

Type    

class

[gl]

Inheritance

Sound ⟶ Object


Overview

play mp3 or wav file


See also 





Overview


Play mp3, wav files



Syntax



Sound(url [, volumn]) 


    • url - (required) url of the sound file

    • volumn - (optional) volumn (0~1) of the sound (default = 1)


Methods


method

description

return

obj:play()

play the sound once

self

obj:play(loops)

play the sound loops times (if loops is INF, then plays the sound file repetedly infdefinitely)

self

obj:stop()

stop playing

self

obj:setVolumn(v)

set volumn as v

self

obj:pause()

pause playing

self

obj:resume()

resume playing

self


static methods :

method

description

return

Sound.setVolumnAll(v)

Set the volume of all sounds to v 

nil

Sound.stopAll()

stop all sounds

nill

Sound.pauseAll()

pause all sounds

nil

Sound.resumeAll()

resume all sounds

nil



Examples



local s = Sound('warning.wav'):play()


local bgmusic = Sound('waytohome.mp3', 0.5) -- set volume as 0.5

bgmusic:play(INF) -- repeat forever


댓글 없음:

댓글 쓰기