|
LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
|
Playing music and sounds. More...
Supported formats: .MP3, .WAV, .OGG, .FLAC, .OPUS and tracker modules (.MOD, .XM, .IT, .S3M, ...). The format is picked from the file extension. Any other file is played as raw 16-bit stereo PCM at 48000 Hz.
Every function that takes an audio as its first parameter can also be called as a method:
Functions | |
| audio | audio.load (string path) |
| nil | audio.play (audio audio, boolean loop) |
| nil | audio.stop (audio audio) |
| nil | audio.pause (audio audio, boolean pause) |
| boolean | audio.playing (audio audio) |
| boolean | audio.paused (audio audio) |
| nil | audio.seek (audio audio, number seconds) |
| nil | audio.volume (audio audio, number left, number right) |
| number | audio.duration (audio audio) |
| number | audio.elapsed (audio audio) |
| table | audio.id3v1 (audio audio) |
| table | audio.id3v2 (audio audio) |
| table | audio.comment (audio audio) |
| table | audio.tags (audio audio) |
| table audio.comment | ( | audio | audio | ) |
Gets the Vorbis comments (tags) of an .OGG file
Method form: snd:comment()
| audio | The audio (.OGG only) |
nil if it isn't an .OGG file, otherwise a table with these string fields:titlealbumartistyearcommentgenre | number audio.duration | ( | audio | audio | ) |
Gets the total length of an audio
Method form: snd:duration()
| audio | The audio |
nil if it's unknown | number audio.elapsed | ( | audio | audio | ) |
Gets how far an audio has played
Method form: snd:elapsed()
| audio | The audio |
nil if it's unknown | table audio.id3v1 | ( | audio | audio | ) |
Gets the ID3v1 tag of an .MP3 file
Method form: snd:id3v1()
| audio | The audio (.MP3 only) |
nil if there is no ID3v1 tag, otherwise a table with these string fields:titleartistalbumcommentyeartaggenre | table audio.id3v2 | ( | audio | audio | ) |
Gets the ID3v2 tag of an .MP3 file
Method form: snd:id3v2()
| audio | The audio (.MP3 only) |
nil if there is no ID3v2 tag, otherwise a table with these fields:titleartistalbumcommentyeargenrecover: The album cover (.JPG or .PNG), if there is one | audio audio.load | ( | string | path | ) |
Loads an audio file
| path | Path to the file (e.g. "app0:music.mp3") |
| nil audio.pause | ( | audio | audio, |
| boolean | pause ) |
Pauses or resumes an audio
Method form: snd:pause(pause)
| audio | The audio |
| pause | true to pause, false to resume |
| boolean audio.paused | ( | audio | audio | ) |
Checks if an audio is paused
Method form: snd:paused()
| audio | The audio |
true if paused | nil audio.play | ( | audio | audio, |
| boolean | loop ) |
Starts playing an audio, from the beginning if it wasn't already playing
Method form: snd:play(loop)
| audio | The audio |
| loop | true to start over every time it ends (optional, default: false) |
| boolean audio.playing | ( | audio | audio | ) |
Checks if an audio is playing
Method form: snd:playing()
| audio | The audio |
true while the audio is playing (also while it's paused), false once it has finished | nil audio.seek | ( | audio | audio, |
| number | seconds ) |
Jumps to a position in the audio
Method form: snd:seek(seconds)
| audio | The audio |
| seconds | Position to jump to, in seconds from the start |
| nil audio.stop | ( | audio | audio | ) |
Stops the audio output completely. Use audio.pause() if you want to continue later.
Method form: snd:stop()
| audio | The audio |
| table audio.tags | ( | audio | audio | ) |
Gets the tags of an .OPUS file
Method form: snd:tags()
| audio | The audio (.OPUS only) |
nil if it isn't an .OPUS file, otherwise a table with these fields:titlealbumartistdatecommentgenreimage: The front cover, if there is one | nil audio.volume | ( | audio | audio, |
| number | left, | ||
| number | right ) |
Sets the volume of the audio
Method form: snd:volume(left, right)
| audio | The audio |
| left | Volume from 0 to 100 (optional, default: 100) |
| right | Volume of the right speaker from 0 to 100 (optional, default: same as left) |