Player APIgetState
getState
Read a synchronous snapshot of the current player state.
window.Moviie.getState() returns a serialisable snapshot of every
runtime field that describes the player at this moment. It is the safest
way to inspect the player from your code: the shape is stable across
versions and the result is JSON-friendly so it can be forwarded to your
analytics pipeline as-is.
Example
const state = window.Moviie.getState()
console.log(state.paused) // false
console.log(state.currentTime) // 12.387
console.log(state.duration) // 421.0
console.log(state.muted) // false
console.log(state.fullscreen) // falseState shape
interface PlayerState {
// Time
currentTime: number
duration: number
buffered: number
played: number
// Playback state
paused: boolean
ended: boolean
seeking: boolean
waiting: boolean
ready: boolean
// Volume
volume: number
muted: boolean
// Display
fullscreen: boolean
pip: boolean
// Playback
playbackRate: number
playbackQuality: string | null
availableQualities: string[]
// Media info
videoWidth: number
videoHeight: number
// Versioning
version: string
}See the State shape reference for a field-by-field description.
When to use it
- Booting your UI — read the state once after
readyto render the initial controls. - Snapshotting for analytics — call
getState()from inside event handlers to enrich events with the full context. - Resilient resume — persist
currentTimeperiodically (e.g. onpause/ended) and pass it back through thestartURL parameter on the next session.
Don't poll getState
getState() is cheap, but events are cheaper. If you only need to
react to changes, subscribe to the relevant event (play, pause,
volumechange, …) instead of polling.