Lib Music

From Elite Wiki
Revision as of 18:01, 14 August 2016 by Svengali (talk | contribs) (Documentation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
IconLib.png

Overview

Lib_Music (part of Library) is an expandable event driven music player, but also the successor to Hyperradio.


Events

Events are handled through Oolites handler (e.g. shipExitedWitchspace). Lib_Music uses handlers which are not fired repeatedly and selects one of the music entries randomly for the specified event. Event music is particulary interesting for mission related things.


_addEventMusic

_addEventMusic: function( obj, ID )

Clones the passed Object and adds entries silently to the event Arrays. Without activating the GroupID via _toggleGroup none of them will be played. The passed Object can use any of the members of $media, except radio (which is reserved for queued music)!

Parameters:

obj
Object. See $media for its members. The entries must contain snd: <filename> and dur: duration seconds <integer>.

Returns:

true or false.

Example:

 worldScripts.Lib_Music._addEventMusic({
   aegis:{
     enter:[ {snd:"MyOXP_AegisFile.ogg",dur:98} ]
   }
 },"MyGroupID");


_toggleGroup

_toggleGroup: function( ID )

Toggles the status for GroupID if it exists. If priority mode is active the change is inactive until priority mode is cleared.

Parameters:

ID
String.

Returns:

n
Number. 0 or 1. The current status.


_setPriorityGroup

Take priority for specified GroupID. Resets and stores the current status, disables all other GroupIDs and enables this GroupID. This method is particulary interesting for mission related things.


_clrPriorityGroup

Clear priority mode. Resets the status of all GroupIDs.


$media

 $media = {
   aegis:{enter:[], exit:[]},
   alert:{red:[]},
   docked:{main:[], any:[]},
   exitWS:{inter:[], goneNova:[], doNova:[], standard:[]},
   killed:{any:[]},
   launch:{inter:[], goneNova:[], doNova:[], main:[], any:[]},
   planetIn:{enterMain:[], enterSun:[], any:[]},
   planetOut:{exitMain:[], exitSun:[], any:[]},
   radio:{generic:[]},
   rescued:{any:[]},
   scooped:{any:[]},
   scoopFuel:{fuel:[]}
 };


Channels

Channels are used as playlists. As long as no other event gets triggered and the status doesn't change Lib_Music will continue to pick another one from the currently active radio channel. If a channel is explicitely set via _setChannel() it will use this channel until it gets unset (both docked and inflight). Otherwise - If docked it will use either a channel that is equal to the name of the station or the "generic" channel. Inflight it uses either the "docking" channel for the autopilot, "fight" for dangerous situations or "generic".


_addChannel

_setChannel