Skip to main content

Player

class Player 

The player logic used by the editor and embeddable player.

This class builds on top of the PlaybackManager to provide a simple interface similar to other media players. It plays through the animation using a real-time update loop and optionally synchronises it with audio.

Constructors

constructor

public new Playerproject: Projectsettings: PartialPlayerSettings = {}initialState: PartialPlayerState = {}initialFrame: number = -1: Player

Parameters

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(): SubscribableValueEventnumber

onFrameChanged

public get onFrameChanged(): SubscribableValueEventnumber

onStateChanged

public get onStateChanged(): SubscribableValueEventPlayerState

Events

onRecalculated

public get onRecalculated(): SubscribablevoidEventHandlervoid

Triggered right after recalculation finishes.

Can be used to provide visual feedback.


onRender

public get onRender(): SubscribablevoidAsyncEventHandlervoid

Triggered during each iteration of the update loop when the frame is ready to be rendered.

Player does not perform any rendering on its own. For the animation to be visible, another class must subscribe to this event and perform the rendering 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. Each player is active by default.


addAudioVolume

public addAudioVolumevalue: number: void

Parameters


clampRange

public clampRangeframe: number: number

Parameters


configure

public configuresettings: PlayerSettings: Promisevoid

Parameters


deactivate

public deactivate(): void

Deactivate the player.

Deactivating the player prevents its update loop from running. This should be done before disposing the player, to prevent it from running in the background.

Just pausing the player does not stop the loop.


isInRange

public isInRangeframe: number: boolean

Whether the given frame is inside the animation range.

Parameters

  • frame: number

    The frame to check.


isInUserRange

public isInUserRangeframe: number: boolean

Whether the given frame is inside the user-defined range.

Parameters

  • frame: number

    The frame to check.


requestNextFrame

public requestNextFrame(): void

requestPreviousFrame

public requestPreviousFrame(): void

requestRender

public requestRender(): void

requestReset

public requestReset(): void

requestSeek

public requestSeekvalue: number: void

Parameters


setAudioVolume

public setAudioVolumevalue: number: void

Parameters


setSpeed

public setSpeedvalue: number: void

Parameters


setVariables

public setVariablesvariables: Recordstringunknown: void

Parameters


toggleAudio

public toggleAudiovalue: boolean = ...: void

Parameters


toggleLoop

public toggleLoopvalue: boolean = !this.playerState.current.loop: void

Parameters

  • value: boolean = !this.playerState.current.loop

togglePlayback

public togglePlaybackvalue: boolean = ...: void

Parameters