new VOPlayer(game, assetCache)
This class is used to create platypus.game.voPlayer
and manages playback by only playing one at a time, playing a list, and even handling captions at the same time.
This class borrows heavily from SpringRoll v1 to match the original capabilities exposed for Platypus v1.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
game |
Game
|
The game instance for which to play audio. |
assetCache |
assetManager
|
The Platypus assetManager used to load and unload VO clips. |
Extends
Members
destroyed :Boolean
This read-only property shows whether this Messenger is destroyed.
Properties:
Name | Type | Description |
---|---|---|
destroyed |
- Inherited From:
- Default Value:
- false
- Source:
Type:
-
Boolean
Methods
destroy()
Cleans up this VOPlayer.
- Overrides:
- Source:
getElapsed() → {int}
Calculates the amount of time elapsed in the current playlist of audio/silence.
- Source:
Returns:
- Type:
-
int
The elapsed time in milliseconds.
getMessageIds() → {Array}
This method returns all the messages that this entity is concerned about.
- Inherited From:
- Source:
Returns:
- Type:
-
Array
An array of strings listing all the messages for which this Messenger has handlers.
off(name, callback)
Remove the event listener
- Inherited From:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event; if no name is specifed remove all listeners. |
callback |
function
|
The listener function. |
on(name, callback)
Add an event listener. The parameters for the listener functions depend on the event.
- Inherited From:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event. |
callback |
function
|
The callback function when event is triggered. |
pause()
Pauses the current VO, caption, or silence timer if the VOPlayer is playing.
- Source:
play(idOrList, callbackopt, cancelledCallbackopt)
Plays a single audio alias, interrupting any current playback. Alternatively, plays a list of audio files, timers, and/or functions. Audio in the list will be preloaded to minimize pauses for loading.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
idOrList |
String
|
Array
|
The alias of the audio file to play or the array of items to play/call in order. |
|
callback |
function
|
<optional> |
The function to call when playback is complete. |
cancelledCallback |
function
|
Boolean
|
<optional> |
The function to call when playback
is interrupted with a stop() or play() call. If this value is a boolean
|
resume()
Resumes the current VO, caption, or silence timer if the VOPlayer was paused.
- Source:
Listens to Events:
setCaptionMute(muted)
Whether to mute captions.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
muted |
Boolean
|
setVolume(volume)
Sets the volume of VO playback.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
volume |
Number
|
toString()
Returns a string describing the Messenger as "[Messenger object]".
- Inherited From:
- Source:
Returns:
String
trigger(event, value, debug) → {number}
This method is used by both internal components and external entities to trigger messages. When triggered, Messenger checks through bound handlers to run as appropriate. This handles multiple event structures: "", [], and {}
- Inherited From:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
String
|
Array
|
Object
|
This is the message(s) to process. This can be a string, an object containing an "event" property (and optionally a "message" property, overriding the value below), or an array of the same. |
value |
*
|
This is a message object or other value to pass along to event handler. |
debug |
boolean
|
This flags whether to output message contents and subscriber information to the console during game development. A "value" object parameter (above) will also set this flag if value.debug is set to true. |
Returns:
- Type:
-
number
The number of handlers for the triggered message.
triggerEvent(event, valueopt) → {number}
This method is used by both internal components and external entities to trigger messages on this entity. When triggered, entity checks through bound handlers to run as appropriate. This method is identical to Spring Roll's EventDispatcher.trigger, but uses alternative Array methods to alleviate excessive GC.
- Inherited From:
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
event |
String
|
This is the message to process. |
|||||||||
value |
*
|
<optional> |
This is a message object or other value to pass along to event handler.
|
Returns:
- Type:
-
number
The number of handlers for the triggered message.
unloadSound(sound)
Unloads an audio track this VOPlayer has played.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sound |
string
|
Sound to unload. |
Events
end
Fired when a new VO, caption, or silence timer completes
- Source:
Parameters:
Name | Type | Description |
---|---|---|
currentVO |
String
|
The alias of the VO or caption that has begun, or null if it is a silence timer. |
start
Fired when a new VO, caption, or silence timer begins
- Source:
Parameters:
Name | Type | Description |
---|---|---|
currentVO |
String
|
The alias of the VO or caption that has begun, or null if it is a silence timer. |