Player
class
Player
The player logic used by the editor and embeddable player.
This class builds on top of the
PlaybackManager
to provide a simpleinterface similar to other media players. It plays through the animationusing a real-time update loop and optionally synchronises it with audio.
Constructors
constructor
public
new
Player
project
:
Project
settings
:
Partial
PlayerSettings
=
{}
initialState
:
Partial
PlayerState
=
{}
initialFrame
:
number
=
-1
:
Player
Parameters
-
project : Project -
settings : Partial PlayerSettings = {} -
initialState : Partial PlayerState = {} -
initialFrame : number = -1
Properties
audio
readonly
public
audio
:
AudioManager
logger
readonly
public
logger
:
Logger
playback
readonly
public
playback
:
PlaybackManager
status
readonly
public
status
:
PlaybackStatus
Accessors
onDurationChanged
public
get
onDurationChanged
():
SubscribableValueEvent
number
onFrameChanged
public
get
onFrameChanged
():
SubscribableValueEvent
number
onStateChanged
public
get
onStateChanged
():
SubscribableValueEvent
PlayerState
Events
onRecalculated
public
get
onRecalculated
():
Subscribable
void
EventHandler
void
Triggered right after recalculation finishes.
Can be used to provide visual feedback.
onRender
public
get
onRender
():
Subscribable
void
AsyncEventHandler
void
Triggered during each iteration of the update loop when the frame is readyto be rendered.
Player does not perform any rendering on its own. For the animation to bevisible, another class must subscribe to this event and perform therendering itself.
Stage
can be used to display the animation.
Methods
activate
public
activate
():
void
Activate the player.
A player needs to be active in order for the update loop to run. Eachplayer is active by default.
configure
Parameters
-
settings : PlayerSettings
deactivate
public
deactivate
():
void
Deactivate the player.
Deactivating the player prevents its update loop from running. This shouldbe done before disposing the player, to prevent it from running in thebackground.
Just pausing the player does not stop the loop.
requestNextFrame
public
requestNextFrame
():
void
requestPreviousFrame
public
requestPreviousFrame
():
void
requestReset
public
requestReset
():
void
requestSeek
public
requestSeek
value
:
number
:
void
Parameters
-
value : number
setSpeed
public
setSpeed
value
:
number
:
void
Parameters
-
value : number
setVariables
public
setVariables
variables
:
Record
string
unknown
:
void
Parameters
-
variables : Record string unknown
toggleAudio
public
toggleAudio
value
:
boolean
=
...
:
void
Parameters
-
value : boolean = ...
toggleLoop
public
toggleLoop
value
:
boolean
=
!this.playerState.current.loop
:
void
Parameters
-
value : boolean = !this.playerState.current.loop
togglePlayback
public
togglePlayback
value
:
boolean
=
...
:
void
Parameters
-
value : boolean = ...