Skip to content

Module: src/providers/Vimeo

VisionPlayer engine that connects the Vimeo Player API with the media API and controls the Vimeo iframe element. Emits synthetic media events and mirrors Vimeo state into the unified player state. Supports playback, pause, loop, seek, playback rate, PiP, volume/mute, subtitles, quality and language.

Version
1.0.0
Author
Frank Kudermann - alphanull
License
MIT
Requires
DomSmith
AsyncTask
ExtendedMediaError
object
scriptLoader
Source
Vimeo.js, line 21

Constructor

new Vimeo(player, parent, options)

Creates an instance of the Vimeo engine.

Parameters:
Name Type Description
player Player

Reference to the player instance.

parent Object

Reference to the parent component (unused for engines).

options Object

Additional options.

Parameters:
Name Type Description
apiKey symbol

Token for extended access to the player API.

Members

Holds the instance configuration for this component.

Properties
Name Type Attributes Default Description
lazyLoadLib boolean optional true

If true, load Vimeo Player API on engine activation as opposed to the earlier initialisation stage.

doNotTrack boolean optional true

If true, enables Vimeo's Do Not Track parameter to reduce tracking and cookie usage. Note: Essential cookies (e.g., for security and bot protection) may still be set even when enabled.

Type
Object
Source
Vimeo.js, line 29

Reference to the main player instance.

Type
Player
Source
Vimeo.js, line 38

Secret key only known to the player instance and initialized components. Used to restrict access to API methods in secure mode.

Type
symbol
Source
Vimeo.js, line 45

Holds metadata information provided by media.load.

Type
Media~metaData
Source
Vimeo.js, line 51

Reference to the Vimeo player instance.

Type
Object
Source
Vimeo.js, line 57

Reference to the Async Task instance. Used to handle async tasks, which can be cancelled, resolved or rejected.

Type
AsyncTask
Source
Vimeo.js, line 63

Cancelable promise for script loading. Used to prevent callbacks when destroyed.

Type
Promise | null
Source
Vimeo.js, line 69

Holds tokens of subscriptions to player events, for later unsubscribe.

Type
Array<number>
Source
Vimeo.js, line 75

Local state mirror (backing values).

Type
Object
Source
Vimeo.js, line 81

DOM helper wrapper around the Vimeo iframe container.

Type
DomSmith
Source
Vimeo.js, line 87

Subtitle renderer instance used to mirror cue changes into the player UI.

Type
Object | null
Source
Vimeo.js, line 93

Internal flag for PiP state.

Type
boolean
Source
Vimeo.js, line 99

Remembers the last invoked Vimeo API method to disambiguate error handling.

Type
'requestPictureInPicture' | null
Source
Vimeo.js, line 105

List of available qualities (could be numeric or textual, but can also be "null" which means "auto").

Type
Array<(null|number|string)>
Source
Vimeo.js, line 111

Fallback empty TimeRanges-like object.

Type
Object
Source
Vimeo.js, line 1017

Default state object for the Vimeo engine.

Type
Object
Source
Vimeo.js, line 1027

Methods

canPlay(metaData) → 'probably'|''

Checks if this engine can play the given media data, by checking if the source contains a valid Vimeo video ID.

Parameters:
Name Type Description
metaData Media~metaData

The data to test.

Parameters:
Name Type Description
src string

The source URL to test.

Returns

Indicates if stream can be played.

Type 'probably' | ''
Source
Vimeo.js, line 174

private #loadLib() → Promise<Object>

Loads Vimeo Player API via CDN if not present. Uses the centralized scriptLoader utility for deduplication and reliability.

Returns

Cancelable promise that resolves with the Vimeo namespace.

Type Promise<Object>
Source
Vimeo.js, line 186

private #load(metaData, optionsopt) → Promise<Media~metaData>

Loads media into the Vimeo player.

Parameters:
Name Type Attributes Description
metaData Media~metaData

The media data to load.

options Object optional

Additional options.

Parameters:
Name Type Attributes Default Description
seek number optional

Seek position.

play boolean optional

Whether to play after loading.

paused boolean optional true

When true, keep paused unless play overrides.

volume number optional 1

Initial volume between 0 and 1.

muted boolean optional false

Whether to start muted.

ignoreAutoplay boolean optional

If true, ignore autoplay setting.

Returns

Resolves with current metadata once API is available.

Type Promise<Media~metaData>
Source
Vimeo.js, line 229

private #onLoaded() → Promise<void>

Syncs metadata after load and emits Media API events.

Fires
quality/update
quality/active
language/update
language/active
media/loadedmetadata
media/ready
media/loadeddata
media/canplay
media/canplaythrough
media/progress
Returns

Resolves when metadata propagation is complete.

Type Promise<void>
Source
Vimeo.js, line 337

private #getMetaData() Media~metaData

Returns the current metadata.

Returns

The current metadata.

Type Media~metaData
Source
Vimeo.js, line 461

private #play()

Plays the media.

Fires
media/play
Source
Vimeo.js, line 467

private #pause()

Pauses the media.

Fires
media/pause
Source
Vimeo.js, line 479

private #loop(loop)

Sets the loop state.

Parameters:
Name Type Description
loop boolean

Whether to loop.

Fires
media/loop
Source
Vimeo.js, line 492

private #playbackRate(rate)

Sets the playback rate.

Parameters:
Name Type Description
rate number

The playback rate (0.5 to 2).

Fires
media/ratechange
Source
Vimeo.js, line 506

private #seek(time)

Seeks to a specific time.

Parameters:
Name Type Description
time number

The time to seek to (in seconds).

Fires
media/seeking
media/seeked
media/canplay
media/canplaythrough
media/progress
Source
Vimeo.js, line 527

private #volume(volume)

Sets the volume.

Parameters:
Name Type Description
volume number

The volume (0 to 1).

Fires
media/volumechange
Source
Vimeo.js, line 549

private #mute(mute)

Sets the mute state.

Parameters:
Name Type Description
mute boolean

Whether to mute.

Fires
media/volumechange
Source
Vimeo.js, line 565

private #requestPictureInPicture()

Requests Picture-in-Picture mode via Vimeo API.

Fires
media/enterpictureinpicture
Source
Vimeo.js, line 583

private #exitPictureInPicture()

Exits Picture-in-Picture mode via Vimeo API.

Fires
media/leavepictureinpicture
Source
Vimeo.js, line 596

private #onPlay()

Handles Vimeo "play" to keep internal state aligned and propagate the Media API event.

Fires
media/play
Source
Vimeo.js, line 608

private #onPlaying()

Handles Vimeo "playing" to mirror the active playback state.

Fires
media/playing
Source
Vimeo.js, line 620

private #onPause()

Handles Vimeo "pause" and forwards the Media API event.

Fires
media/pause
Source
Vimeo.js, line 631

private #onEnded()

Handles Vimeo "ended", optionally restarts on loop, and fires Media API events.

Fires
media/ended
Source
Vimeo.js, line 642

private #onTimeUpdate(data)

Handles Vimeo "timeupdate" payloads and recomputes derived timing state.

Parameters:
Name Type Description
data Object

Event data from Vimeo.

Parameters:
Name Type Attributes Description
duration number optional

Reported duration.

seconds number optional

Current playback position.

Fires
media/timeupdate
Source
Vimeo.js, line 662

private #onProgress(data)

Handles Vimeo "progress" events and updates buffered range.

Parameters:
Name Type Description
data Object

Event data from Vimeo.

Parameters:
Name Type Attributes Description
duration number optional

Reported duration.

percent number optional

Buffered percent (0..1).

Fires
media/progress
Source
Vimeo.js, line 682

private #onSeeked()

Handles Vimeo "seeked" and forwards Media API event.

Fires
media/seeked
Source
Vimeo.js, line 701

private #onBufferStart()

Handles Vimeo "bufferstart".

Fires
media/waiting
Source
Vimeo.js, line 707

private #onBufferEnd()

Handles Vimeo "bufferend".

Fires
media/canplay
Source
Vimeo.js, line 713

private #onCueChange(event)

Handles Vimeo cue changes and feeds them into the subtitle renderer.

Parameters:
Name Type Description
event Object

Vimeo cue event.

Parameters:
Name Type Attributes Description
cues Array optional

Active cues.

Source
Vimeo.js, line 720

private #onRateChange(data)

Handles Vimeo playback-rate changes.

Parameters:
Name Type Description
data Object

Event data from Vimeo.

Parameters:
Name Type Attributes Description
playbackRate number optional

Updated playback rate.

Fires
media/ratechange
Source
Vimeo.js, line 728

private #onVolumeChange(data)

Handles Vimeo volume changes.

Parameters:
Name Type Description
data Object

Event data from Vimeo.

Parameters:
Name Type Attributes Description
volume number optional

Updated volume (0..1).

muted boolean optional

Muted flag.

Fires
media/volumechange
Source
Vimeo.js, line 743

private #onPipEnter()

Handles Vimeo enter-PiP.

Fires
media/enterpictureinpicture
Source
Vimeo.js, line 756

private #onPipExit()

Handles Vimeo leave-PiP.

Fires
media/leavepictureinpicture
Source
Vimeo.js, line 768

private #onSubtitlesSelected(payloadopt)

Reacts to player subtitle selection updates.

Parameters:
Name Type Attributes Description
payload Object optional

Selection payload.

Parameters:
Name Type Attributes Description
language string optional

Target language or null to disable.

off boolean optional

When true, disable subtitles.

type string optional

Track kind, defaults to "subtitles".

index number optional

Index of the selected track.

Fires
subtitles/active
Listens
subtitles/selected
Source
Vimeo.js, line 786

private #onQualitySelected(payload)

Applies a quality selection coming from the player UI.

Parameters:
Name Type Description
payload Object

Payload emitted by the quality menu.

Parameters:
Name Type Description
quality number | null

Selected resolution (e.g., 720) or null for auto.

Fires
quality/active
Listens
quality/selected
Source
Vimeo.js, line 822

private #onQualityResize(size)

Handler for 'quality/resize' event. Caps the max bitrate if display size is small.

Parameters:
Name Type Description
size Object

Object containing size information.

Parameters:
Name Type Description
height number

The new container height in px.

Listens
quality/resize
Source
Vimeo.js, line 842

private #getBestQuality(height) → number|null

Picks the best quality for a given height.

Parameters:
Name Type Description
height number

The height in pixels.

Returns

The best quality or null if no quality is available.

Type number | null
Source
Vimeo.js, line 857

private #onLanguageSelected(langObj)

Applies an audio language selection coming from the player UI.

Parameters:
Name Type Description
langObj Object

Payload emitted by the language menu.

Parameters:
Name Type Attributes Description
language string optional

Language code.

value string optional

Alternative language key.

Fires
language/active
Listens
language/selected
Source
Vimeo.js, line 875

private #onError(error)

Normalizes Vimeo errors into ExtendedMediaError and forwards notifications where appropriate.

Parameters:
Name Type Description
error Object

Vimeo error object.

Fires
media/error
notification
Source
Vimeo.js, line 892

private #getIFrameElement() → HTMLElement|null

Returns the Vimeo iframe element (falls back to the wrapper if not mounted yet).

Returns

The Vimeo iframe element or wrapper node.

Type HTMLElement | null
Source
Vimeo.js, line 919

async enable()

Enables the Vimeo engine by loading the API, mounting the iframe container and exposing state accessors.

Source
Vimeo.js, line 924

disable()

Disables the Vimeo engine and removes all registered state accessors.

Source
Vimeo.js, line 976

destroy()

This method removes all events, subscriptions and DOM nodes created by this component.

Source
Vimeo.js, line 1002

private, static #toRange(start, end) → Object

Converts start and end times to a TimeRanges-like object.

Parameters:
Name Type Description
start number

Start time.

end number

End time.

Returns

TimeRanges-like object.

Type Object
Source
Vimeo.js, line 1051

private, static #extractVideoId(src) → string|null

Extracts a Vimeo video id from a URL.

Parameters:
Name Type Description
src string

Source URL.

Returns

Video id if found.

Type string | null
Source
Vimeo.js, line 1064