Vimeo Player API
The Vimeo Player API allows you to interact with and control an embedded Vimeo
Player.
Installation
You can install the Vimeo Player API through either npm:
npm install @vimeo/player
Alternatively, you can reference an up‐to‐date version on our CDN:
<script src="https://player.vimeo.com/api/player.js"></script>
Warning: when used with RequireJS it's required to load the script dynamically via the RequireJS load system.
http://www.requirejs.org/docs/api.html#jsfiles
Getting Started
In order to control the Vimeo player, you need a player to control. There are a
few ways to get a player:
Pre-existing player
Already have a player on the page? Pass the element to the Vimeo.Player
constructor and you’re ready to go.
<iframe src="https://player.vimeo.com/video/76979871?h=8272103f6e" width="640" height="360" frameborder="0" allowfullscreen allow="autoplay; encrypted-media"></iframe>
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
const iframe = document.querySelector('iframe');
const player = new Vimeo.Player(iframe);
player.on('play', function() {
console.log('played the video!');
});
player.getVideoTitle().then(function(title) {
console.log('title:', title);
});
</script>
Create with a video id or url
You can use the library to make the embed for you. All you need is an empty
element and the video id or vimeo.com url (and optional
embed options).
NOTE: If the video privacy settings are "Unlisted", instead of providing an id
property, you will need to provide the full video URL as a url
property and include the h
parameter.
<div id="made-in-ny"></div>
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
const options = {
id: 59777392,
width: 640,
loop: true
};
const player = new Vimeo.Player('made-in-ny', options);
player.setVolume(0);
player.on('play', function() {
console.log('played the video!');
});
</script>
Automatically with HTML attributes
When the library loads, it will scan your page for elements with Vimeo
attributes. Each element must have at least a data-vimeo-id
or
data-vimeo-url
attribute in order for the embed to be created automatically.
You can also add attributes for any of the embed options,
prefixed with data-vimeo
(data-vimeo-portrait="false"
, for example).
NOTE: If the video privacy settings are "Unlisted", instead of providing a data-vimeo-id
attribute, you will need to provide the full video URL in a data-vimeo-url
attribute and include the h
parameter.
<div data-vimeo-id="19231868" data-vimeo-width="640" id="handstick"></div>
<div data-vimeo-url="https://player.vimeo.com/video/76979871?h=8272103f6e" id="playertwo"></div>
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
const handstickPlayer = new Vimeo.Player('handstick');
handstickPlayer.on('play', function() {
console.log('played the handstick video!');
});
const playerTwoPlayer = new Vimeo.Player('playertwo');
playerTwoPlayer.on('play', function() {
console.log('played the player 2.0 video!');
});
</script>
Browser Support
The Player API library is supported in IE 11+, Chrome, Firefox, Safari, and
Opera.
Migrate from Froogaloop
Using our old Froogaloop library? See the migration doc
for details on how to update your code to use this library.
Using with a module bundler
If you’re using a module bundler like webpack or
rollup, the exported object will be the Player
constructor (unlike the browser where it is attached to window.Vimeo
):
import Player from '@vimeo/player';
const player = new Player('handstick', {
id: 19231868,
width: 640
});
player.on('play', function() {
console.log('played the video!');
});
Similarly, if you’re using RequireJS in the browser,
it will also import the Player constructor directly:
<iframe src="https://player.vimeo.com/video/76979871?h=8272103f6e" width="640" height="360" frameborder="0" allowfullscreen allow="autoplay; encrypted-media"></iframe>
<script>
require(['https://player.vimeo.com/api/player.js'], function (Player) {
const iframe = document.querySelector('iframe');
const player = new Player(iframe);
player.on('play', function() {
console.log('played the video!');
});
});
</script>
Table of Contents
Create a Player
The Vimeo.Player
object wraps an iframe so you can interact with and control a
Vimeo Player embed.
Existing embed
If you already have a Vimeo <iframe>
on your page, pass that element into the
constructor to get a Player
object. You can also use jQuery to select the
element, or pass a string that matches the id
of the <iframe>
.
const iframe = document.querySelector('iframe');
const iframePlayer = new Vimeo.Player(iframe);
const jqueryPlayer = new Vimeo.Player($('iframe'));
const idPlayer = new Vimeo.Player('player1');
Create an embed
Pass any element and an options object to the Vimeo.Player
constructor to make
an embed inside that element. The options object should consist of either an
id
or url
and any other embed options for the embed.
NOTE: If the video privacy settings are "Unlisted", instead of providing an id
property, you will need to provide the full video URL as a url
property and include the h
parameter.
<div id="made-in-ny"></div>
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
const options = {
id: 59777392,
width: 640,
loop: true
};
const madeInNy = new Vimeo.Player('made-in-ny', options);
</script>
Embed options will also be read from the data-vimeo-*
attributes. Attributes
on the element will override any defined in the options object passed to the
constructor (similar to how the style
attribute overrides styles defined in
CSS).
Elements with a data-vimeo-id
or data-vimeo-url
attribute will have embeds
created automatically when the player API library is loaded. You can use the
data-vimeo-defer
attribute to prevent that from happening and create the embed
at a later time. This is useful for situations where the player embed wouldn’t
be visible right away, but only after some action was taken by the user (a
lightbox opened from clicking on a thumbnail, for example).
<div data-vimeo-id="59777392" data-vimeo-defer id="made-in-ny"></div>
<div data-vimeo-id="19231868" data-vimeo-defer data-vimeo-width="500" id="handstick"></div>
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
const options = {
width: 640,
loop: true
};
const madeInNy = new Vimeo.Player('made-in-ny', options);
const handstick = new Vimeo.Player(document.getElementById('handstick'), options);
</script>
Embed Options
These options are available to be appended to the query string of the player URL, used as data-vimeo-
attributes on elements, or included as
an object passed to the Vimeo.Player
constructor. The complete list of embed options can be found in our official SDK documentation.
Methods
You can call methods on the player by calling the function on the Player object:
player.play();
All methods, except for on()
and off()
return a
Promise. The Promise may
or may not resolve with a value, depending on the specific method.
player.disableTextTrack().then(function() {
}).catch(function(error) {
});
Promises for getters are resolved with the value of the property:
player.getLoop().then(function(loop) {
});
Promises for setters are resolved with the value set, or rejected with an error
if the set fails. For example:
player.setColor('#00adef').then(function(color) {
}).catch(function(error) {
});
on(event: string, callback: function): void
Add an event listener for the specified event. Will call the callback with a
single parameter, data
, that contains the data for that event. See
events below for details.
const onPlay = function(data) {
};
player.on('play', onPlay);
off(event: string, callback?: function): void
Remove an event listener for the specified event. Will remove all listeners for
that event if a callback
isn’t passed, or only that specific callback if it is
passed.
const onPlay = function(data) {
};
player.on('play', onPlay);
player.off('play', onPlay);
player.off('play');
loadVideo(options: number|string|object): Promise<number|object, (TypeError|PasswordError|Error)>
Load a new video into this embed. The promise will be resolved if the video is
successfully loaded, or it will be rejected if it could not be loaded.
NOTE: If the video privacy settings are "Unlisted", instead of providing an id
argument, you will need to provide the full video URL as a url
argument and include the h
parameter.
player.loadVideo(76979871).then(function(id) {
}).catch(function(error) {
switch (error.name) {
case 'TypeError':
break;
case 'PasswordError':
break;
case 'PrivacyError':
break;
default:
break;
}
});
ready(): Promise<void, Error>
Trigger a function when the player iframe has initialized. You do not need to
wait for ready
to trigger to begin adding event listeners or calling other
methods.
player.ready().then(function() {
});
enableTextTrack(language: string, kind?: string): Promise<object, (InvalidTrackLanguageError|InvalidTrackError|Error)>
Enable the text track with the specified language, and optionally the specified
kind (captions or subtitles).
When set via the API, the track language will not change the viewer’s stored
preference.
player.enableTextTrack('en').then(function(track) {
}).catch(function(error) {
switch (error.name) {
case 'InvalidTrackLanguageError':
break;
case 'InvalidTrackError':
break;
default:
break;
}
});
disableTextTrack(): Promise<void, Error>
Disable the currently-active text track.
player.disableTextTrack().then(function() {
}).catch(function(error) {
});
pause(): Promise<void, (PasswordError|PrivacyError|Error)>
Pause the video if it’s playing.
player.pause().then(function() {
}).catch(function(error) {
switch (error.name) {
case 'PasswordError':
break;
case 'PrivacyError':
break;
default:
break;
}
});
play(): Promise<void, (PasswordError|PrivacyError|Error)>
Play the video if it’s paused. Note: on iOS and some other mobile devices,
you cannot programmatically trigger play. Once the viewer has tapped on the play
button in the player, however, you will be able to use this function.
player.play().then(function() {
}).catch(function(error) {
switch (error.name) {
case 'PasswordError':
break;
case 'PrivacyError':
break;
default:
break;
}
});
unload(): Promise<void, Error>
Return the internal player (iframe) to its initial state.
player.unload().then(function() {
}).catch(function(error) {
});
destroy(): Promise<void, Error>
Cleanup the player and remove it from the DOM.
It won't be usable and a new one should be constructed
in order to do any operations.
player.destroy().then(function() {
}).catch(function(error) {
});
requestFullscreen(): Promise<void, Error>
Request the player enters fullscreen.
player.requestFullscreen().then(function() {
}).catch(function(error) {
});
exitFullscreen(): Promise<void, Error>
Request the player exits fullscreen.
player.exitFullscreen().then(function() {
}).catch(function(error) {
});
getFullscreen(): Promise<boolean, Error>
Checks whether the player is currently fullscreen.
player.getFullscreen().then(function(fullscreen) {
}).catch(function(error) {
});
requestPictureInPicture(): Promise<void, Error>
Request the player enters picture-in-picture.
player.requestPictureInPicture().then(function() {
}).catch(function(error) {
});
exitPictureInPicture(): Promise<void, Error>
Request the player exits picture-in-picture.
player.exitPictureInPicture().then(function() {
}).catch(function(error) {
});
getPictureInPicture(): Promise<boolean, Error>
Checks whether the player is currently picture-in-picture.
player.getPictureInPicture().then(function(pip) {
}).catch(function(error) {
});
remotePlaybackPrompt(): Promise<void, Error>
Prompt the viewer to activate or deactivate a remote playback device, if one is available.
Note: This method may require user interaction directly with the player before working properly and must be triggered by a user interaction. It is best to wait for initial playback before calling this method.
player.remotePlaybackPrompt().then(function() {
}).catch(function(error) {
switch (error.name) {
case 'NotFoundError':
break;
default:
break;
}
});
getRemotePlaybackAvailability(): Promise<string, Error>
Checks if there is a remote playback device available.
player.getRemotePlaybackAvailability().then(function(remotePlaybackAvailable) {
}).catch(function(error) {
})
getRemotePlaybackState(): Promise<boolean, Error>
Get the current state of remote playback. Can be one of connecting
, connected
, or disconnected
. These values are equivalent to the state values in the Remote Playback API.
player.getRemotePlaybackState().then(function(remotePlaybackState) {
}).catch(function(error) {
})
getAutopause(): Promise<boolean, (UnsupportedError|Error)>
Get the autopause behavior for this player.
player.getAutopause().then(function(autopause) {
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
break;
default:
break;
}
});
setAutopause(autopause: boolean): Promise<boolean, (UnsupportedError|Error)>
Enable or disable the autopause behavior of this player. By default, when
another video is played in the same browser, this player will automatically
pause. Unless you have a specific reason for doing so, we recommend that you
leave autopause set to the default (true
).
player.setAutopause(false).then(function(autopause) {
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
break;
default:
break;
}
});
getBuffered(): Promise<array, Error>
Get the buffered time ranges of the video.
player.getBuffered().then(function(buffered) {
}).catch(function(error) {
});
getChapters(): Promise<array, Error>
Get an array of the chapters that are on the video.
player.getChapters().then(function(chapters) {
}).catch(function(error) {
});
Each chapters object looks like this:
{
"startTime": 15,
"title": "Chapter Title",
"index": 1
}
getCurrentChapter(): Promise<object, Error>
Get the current chapter. A chapter is "current" when the currentTime
of the video is equal to or after its startTime
and before the startTime
of the next chapter or the end of the video.
player.getCurrentChapter().then(function(chapter) {
}).catch(function(error) {
});
getColor(): Promise<string, Error>
Get the accent color for this player. Note that this is deprecated in place of getColors
.
player.getColor().then(function(color) {
}).catch(function(error) {
});
getColors(): Promise<string[], Error>
Get all colors used for this player.
The return value is an array of primary, accent, text/icon, and background.
player.getColors().then(function(colors) {
}).catch(function(error) {
});
setColor(color: string): Promise<string, (ContrastError|TypeError|Error)>
Set the accent color of this player to a hex or rgb string. Setting the color may fail
if the owner of the video has set their embed preferences to force a specific
color. Note that this setter is deprecated and should be replaced with setColors
.
player.setColor('#00adef').then(function(color) {
}).catch(function(error) {
switch (error.name) {
case 'TypeError':
break;
case 'EmbedSettingsError':
break;
default:
break;
}
});
setColors(colors: string[]): Promise<string[], (ContrastError|TypeError|Error)>
Set all colors of this player with an array of hex values. Setting the color may fail
if the owner of the video has set their embed preferences to force a specific
color.
player.setColors(['abc', 'def', '123', '456']).then(function(color) {
}).catch(function(error) {
switch (error.name) {
case 'TypeError':
break;
case 'EmbedSettingsError':
break;
default:
break;
}
});
addCuePoint(time: number, data: object): Promise<string, (UnsupportedError|RangeError|Error)>
Add a cue point to the player. Cue points fire a cuepoint
event when the
currentTime
of the video passes the specified time. Note: cue points should
be accurate to within a tenth of a second, but the precision may vary based on
browser or environment.
player.addCuePoint(15, {
customKey: 'customValue'
}).then(function(id) {
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
break;
case 'RangeError':
break;
default:
break;
}
});
removeCuePoint(id: string): Promise<string, (UnsupportedError|InvalidCuePoint|Error)>
Remove the specified cue point using the id returned from addCuePoint()
or
from getCuePoints()
.
player.removeCuePoint('09ecf4e4-b587-42cf-ad9f-e666b679c9ab').then(function(id) {
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
break;
case 'InvalidCuePoint':
break;
default:
break;
}
});
getCuePoints(): Promise<array, (UnsupportedError|Error)>
Get an array of the cue points that have been added to the video.
player.getCuePoints().then(function(cuePoints) {
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
break;
default:
break;
}
});
Each cue point object looks like this:
{
"time": 15,
"data": {
"customKey": "customValue"
},
"id": "09ecf4e4-b587-42cf-ad9f-e666b679c9ab"
}
getCurrentTime(): Promise<number, Error>
Get the current playback position in seconds.
player.getCurrentTime().then(function(seconds) {
}).catch(function(error) {
});
setCurrentTime(seconds: number): Promise<number, (RangeError|Error)>
Set the current playback position in seconds. Once playback has started, if the
player was paused, it will remain paused. Likewise, if the player was playing,
it will resume playing once the video has buffered. Setting the current time
before playback has started will cause playback to start.
You can provide an accurate time and the player will attempt to seek to as close
to that time as possible. The exact time will be the fulfilled value of the
promise.
player.setCurrentTime(30.456).then(function(seconds) {
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
break;
default:
break;
}
});
getDuration(): Promise<number, Error>
Get the duration of the video in seconds. It will be rounded to the nearest
second before playback begins, and to the nearest thousandth of a second after
playback begins.
player.getDuration().then(function(duration) {
}).catch(function(error) {
});
getEnded(): Promise<boolean, Error>
Get the ended state of the video. The video has ended if
currentTime === duration
.
player.getEnded().then(function(ended) {
}).catch(function(error) {
});
getLoop(): Promise<boolean, Error>
Get the loop state of the player.
player.getLoop().then(function(loop) {
}).catch(function(error) {
});
setLoop(loop: boolean): Promise<boolean, Error>
Set the loop state of the player. When set to true
, the player will start over
immediately once playback ends. Note: when loop is turned on, the ended
event will not fire.
player.setLoop(true).then(function(loop) {
}).catch(function(error) {
});
getMuted(): Promise<boolean, Error>
Get the muted state of the player.
player.getMuted().then(function(muted) {
}).catch(function(error) {
});
setMuted(muted: boolean): Promise<boolean, Error>
Set the muted state of the player. When set to true
, the player volume will be muted.
player.setMuted(true).then(function(muted) {
}).catch(function(error) {
});
getPaused(): Promise<boolean, Error>
Get the paused state of the player.
player.getPaused().then(function(paused) {
}).catch(function(error) {
});
getPlaybackRate(): Promise<number, Error>
Get the playback rate of the player on a scale from 0
to 2
.
player.getPlaybackRate().then(function(playbackRate) {
}).catch(function(error) {
});
setPlaybackRate(playbackRate: number): Promise<number, (RangeError|Error)>
Set the playback rate of the player on a scale from 0
to 2
(available to PRO and Business accounts). When set
via the API, the playback rate will not be synchronized to other
players or stored as the viewer's preference.
player.setPlaybackRate(0.5).then(function(playbackRate) {
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
break;
default:
break;
}
});
getPlayed(): Promise<array, Error>
Get the played time ranges of the video.
player.getPlayed().then(function(played) {
}).catch(function(error) {
});
getSeekable(): Promise<array, Error>
Get the video time ranges that are seekable.
player.getSeekable().then(function(seekable) {
}).catch(function(error) {
});
getSeeking(): Promise<boolean, Error>
Get if the player is currently seeking.
player.getSeeking().then(function(seeking) {
}).catch(function(error) {
});
getTextTracks(): Promise<object[], Error>
Get an array of the text tracks that exist for the video. For example:
player.getTextTracks().then(function(tracks) {
}).catch(function(error) {
});
Each track object looks like this:
{
"label": "English CC",
"language": "en",
"kind": "captions",
"mode": "showing"
}
Kind can be either captions
or subtitles
. The mode can be either showing
or disabled
. Only one track can be showing
at any given time; the rest will
be disabled
.
getVideoEmbedCode(): Promise<string, Error>
Get the <iframe>
embed code for the video.
player.getVideoEmbedCode().then(function(embedCode) {
}).catch(function(error) {
});
getVideoId(): Promise<number, Error>
Get the id of the video.
player.getVideoId().then(function(id) {
}).catch(function(error) {
});
getVideoTitle(): Promise<string, Error>
Get the title of the video.
player.getVideoTitle().then(function(title) {
}).catch(function(error) {
});
getVideoWidth(): Promise<number, Error>
Get the native width of the currently‐playing video. The width of the highest
resolution available will be used before playback begins.
player.getVideoWidth().then(function(width) {
}).catch(function(error) {
});
getVideoHeight(): Promise<number, Error>
Get the native height of the currently‐playing video. The height of the highest
resolution available will be used before playback begins.
player.getVideoHeight().then(function(height) {
}).catch(function(error) {
});
To get both the width and height, you can do this:
Promise.all([player.getVideoWidth(), player.getVideoHeight()]).then(function(dimensions) {
var width = dimensions[0];
var height = dimensions[1];
});
getVideoUrl(): Promise<string, (PrivacyError|Error)>
Get the vimeo.com url for the video.
player.getVideoUrl().then(function(url) {
}).catch(function(error) {
switch (error.name) {
case 'PrivacyError':
break;
default:
break;
}
});
getVolume(): Promise<number, Error>
Get the current volume level of the player on a scale from 0
to 1
.
Most mobile devices do not support an independent volume from the system volume.
In those cases, this method will always return 1
.
player.getVolume().then(function(volume) {
}).catch(function(error) {
});
setVolume(volume: number): Promise<number, (RangeError|Error)>
Set the volume of the player on a scale from 0
to 1
. When set via the API,
the volume level will not be synchronized to other players or stored as the
viewer’s preference.
Most mobile devices (including iOS and Android) do not support setting the
volume because the volume is controlled at the system level. An error will not
be triggered in that situation.
player.setVolume(0.5).then(function(volume) {
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
break;
default:
break;
}
});
setTimingSrc(timingObject: TimingObject, options?: TimingSrcConnectorOptions): Promise<TimingSrcConnector>
Syncs a Timing Object to the video player (https://webtiming.github.io/timingobject/)
npm install @vimeo/player timing-object
<div id="handstick"></div>
import Player from '@vimeo/player';
import {TimingObject} from 'timing-object';
const player = new Player('handstick', {
id: 19231868,
width: 640
});
const timingObject = new TimingObject();
player.setTimingSrc(timingObject)
player.setTimingSrc(timingObject, {role: 'controller'})
See TimingSrcConnectorOptions for available options.
See this demo app which syncs video playback in real-time for all viewers.
getQualities(): Promise<object[], Error>
Get the available qualities of the current video.
player.getQualities().then(function(qualities) {
}).catch(function(error) {
});
Each quality object looks like this:
{
"label": "4K",
"id": "2160p",
"active": true
}
getQuality(): Promise<string, Error>
Get the current selected quality.
player.getQuality().then(function(quality) {
}).catch(function(error) {
});
setQuality(quality: string): Promise<string, (TypeError|Error)>
Set the quality of the video. (available to Plus, PRO and Business accounts)
player.setQuality('720p').then(function(quality) {
}).catch(function(error) {
switch (error.name) {
case 'TypeError':
break;
default:
break;
}
});
getCameraProps(): Promise<object, Error>
Get the current camera properties for a 360° video.
player.getCameraProps().then(function(cameraProps) {
}).catch(function(error) {
});
Each cameraProps
object looks like this:
{
"yaw": 360,
"pitch": 90,
"roll": 180,
"fov": 45
}
setCameraProps(cameraProps: object): Promise<object, (RangeError|Error)>
Set the camera properties for a 360° video.
player.setCameraProps({
"yaw": 360,
"pitch": 90,
"roll": 180,
"fov": 45
}).then(function(cameraProps) {
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
break;
default:
break;
}
});
Events
You can listen for events in the player by attaching a callback using .on()
:
player.on('eventName', function(data) {
});
The events are equivalent to the HTML5 video events (except for cuechange
,
which is slightly different).
To remove a listener, call .off()
with the callback function:
var callback = function() {};
player.off('eventName', callback);
If you pass only an event name, all listeners for that event will be removed.
play
Triggered when video playback is initiated.
{
duration: 61.857
percent: 0
seconds: 0
}
playing
Triggered when the video starts playing.
{
duration: 61.857
percent: 0
seconds: 0
}
pause
Triggered when the video pauses.
{
duration: 61.857
percent: 0
seconds: 0
}
ended
Triggered any time the video playback reaches the end. Note: when loop is
turned on, the ended
event will not fire.
{
duration: 61.857
percent: 1
seconds: 61.857
}
timeupdate
Triggered as the currentTime
of the video updates. It generally fires every
250ms, but it may vary depending on the browser.
{
duration: 61.857
percent: 0.049
seconds: 3.034
}
progress
Triggered as the video is loaded. Reports back the amount of the video that has
been buffered.
{
duration: 61.857
percent: 0.502
seconds: 31.052
}
seeking
Triggered when the player starts seeking to a specific time. A timeupdate
event will
also be fired at the same time.
{
duration: 61.857
percent: 0.485
seconds: 30
}
seeked
Triggered when the player seeks to a specific time. A timeupdate
event will
also be fired at the same time.
{
duration: 61.857
percent: 0.485
seconds: 30
}
texttrackchange
Triggered when the active text track (captions/subtitles) changes. The values
will be null if text tracks are turned off.
{
kind: "captions",
label: "English CC",
language: "en"
}
chapterchange
Triggered when the current chapter changes.
{
startTime: 15,
title: "Chapter 1",
index: 1
}
The index
property of each chapter is the place it holds in the order of all the chapters. It starts at 1.
cuechange
Triggered when the active cue for the current text track changes. It also fires
when the active text track changes. There may be multiple cues active.
{
cues: [
{
html: "<i>Here at Vimeo, there's always <br>one thing on our minds:</i>",
text: "<i>Here at Vimeo, there's always ↵one thing on our minds:</i>"
}
],
kind: "captions",
label: "English CC",
language: "en"
}
The text
property of each cue is the raw value parsed from the caption or
subtitle file. The html
property contains the HTML that the Player renders for
that cue.
cuepoint
Triggered when the current time hits a registered cue point.
{
time: 15,
data: {
customKey: 'customValue'
},
id: "40f5722b-09aa-4060-a887-3c81aaa37cce"
}
The data
property will be the custom data provided in the addCuePoint()
call, or an empty object if none was provided.
volumechange
Triggered when the volume in the player changes. Some devices do not support
setting the volume of the video independently from the system volume, so this
event will never fire on those devices.
{
volume: 0.5
}
playbackratechange
Triggered when the playback rate of the video in the player changes. The ability to change rate can be disabled by the creator
and the event will not fire for those videos. The new playback rate is returned with the event.
{
playbackRate: 1.5
}
bufferstart
Triggered when buffering starts in the player. This is also triggered during preload and while seeking. There is no associated data with this event.
bufferend
Triggered when buffering ends in the player. This is also triggered at the end of preload and seeking. There is no associated data with this event.
error
Triggered when some kind of error is generated in the player. In general if you
are using this API library, you should use .catch()
on each method call
instead of globally listening for error events.
If the error was generated from a method call, the name of that method will be
included.
{
message: "#984220 does not meet minimum contrast ratio. We recommend using brighter colors. (You could try #d35e30 instead.) See WCAG 2.0 guidelines: http://www.w3.org/TR/WCAG/#visual-audio-contrast"
method: "setColor"
name: "ContrastError"
}
loaded
Triggered when a new video is loaded in the player.
{
id: 76979871
}
durationchange
Triggered when the duration attribute has been updated.
{
duration: 60
}
fullscreenchange
Triggered when the player enters or exits fullscreen.
{
fullscreen: true
}
qualitychange
Triggered when the set quality changes.
{
quality: '720p'
}
camerachange
Triggered when any of the camera properties change for 360° videos.
{
yaw: 270,
pitch: 90,
roll: 0,
fov: 45
}
resize
Triggered when the intrinsic size of the media changes.
{
videoWidth: 1280,
videoHeight: 720
}
enterpictureinpicture
Triggered when the player enters picture-in-picture.
leavepictureinpicture
Triggered when the player leaves picture-in-picture.
remoteplaybackavailabilitychange
Triggered when the availability of remote playback changes.
Listening for this event is equivalent to the RemotePlayback.watchAvailability() API, except that there is no cancelWatchAvailability()
. You can remove the listener for this event instead.
remoteplaybackconnecting
Triggered when the player is attempting to connect to a remote playback device.
remoteplaybackconnect
Triggered when the player has successfully connected to a remote playback device.
remoteplaybackdisconnect
Triggered when the player has disconnected from a remote playback device.
interactivehotspotclicked
Triggered when a hotspot is clicked.
{
action: 'seek',
actionPreference: {
pauseOnAction: false,
overlayId: 864334,
seekTo: 30,
url: 'https://your-url.com',
},
currentTime: 15.585,
customPayloadData: null,
hotspotId: 8148223
}
interactiveoverlaypanelclicked
Triggered when the overlay panel (buttons or images) within the interactive overlay is clicked.
{
action: 'seek',
actionPreference: {
pauseOnAction: true,
seekTo: 30,
url: 'https://your-url.com',
},
currentTime: 25.67,
customPayloadData: null,
overlayId: 864334,
panelId: 'c47193a0-8320-4572-9bcd-8425851b36e9'
}