Music Player
MusicPlayer, a static global class, is the in-game music player. It allows you to control the music player in the same way that the in-game music player user interface does.
Example usage: MusicPlayer.repeat_track = true
.
Member Variables
Like Object member variables, MusicPlayer has its own member variables. They allow for direct access to the MusicPlayer's property information without a helping function. Some are read-only.
Function Summary
MusicPlayer Functions
Functions that interact with the in-game music player.
Function Details
play()
Plays currently loaded audioclip. Returns true if the music player is playing, otherwise returns false.
--Example Usage startLuaCoroutine(self, "PlayMusic") --Plays currently loaded audioclip when everyone has loaded the audioclip. function PlayMusic() --Wait for everyone to load the audioclip. while MusicPlayer.loaded == false do coroutine.yield(0) end --Play audioclip. MusicPlayer.play() return 1 end
pause()
Pauses currently playing audioclip. Returns true if the music player is paused, otherwise returns false.
--Example Usage startLuaCoroutine(self, "PauseMusic") --Pauses the currently playing audioclip after 1000 frames. function PauseMusic() --Wait 1000 frames for i=1,1000 do coroutine.yield(0) end --Pause audioclip MusicPlayer.pause() return 1 end
skipForward()
Skips to the next audioclip in playlist if possible. Returns true if skip was successful, otherwise returns false.
--Example Usage MusicPlayer.skipForward()
skipBack()
Skips to the beginning of the audioclip or if the play time is less than 3 seconds to the previous audioclip in playlist if possible. Returns true if skip was successful, otherwise returns false.
--Example Usage MusicPlayer.skipBack()
getCurrentAudioclip()
Gets the currently loaded audioclip.
--Example Usage currentAudioclip = MusicPlayer.getCurrentAudioclip()
--Example Returned Table {url="Audioclip Url", title="Audioclip Title"}
setCurrentAudioclip(...)
.Sets the audioclip to be loaded.
setCurrentAudioclip(parameters)
--Example Usage parameters = { url="SOME URL HERE", title="SOME TITLE HERE" } MusicPlayer.setCurrentAudioclip(parameters)
getPlaylist()
--Example Usage playlist = MusicPlayer.getPlaylist()
--Example Returned Table { {url="Audioclip Url 1", title="Audioclip Title 1"}, {url="Audioclip Url 2", title="Audioclip Title 2"}, {url="Audioclip Url 3", title="Audioclip Title 3"} }
setPlaylist(...)
setPlaylist(parameters)
--Example Usage parameters = { {url="SOME URL HERE 1",title="SOME TITLE HERE 1"}, {url="SOME URL HERE 2",title="SOME TITLE HERE 2"}, {url="SOME URL HERE 3",title="SOME TITLE HERE 3"} } MusicPlayer.setPlaylist(parameters)