mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Updated typings to match Vimeo's player.js v2.6.3, updated tests to reflect new methods, properties, and events
This commit is contained in:
Vendored
+12
-2
@@ -1,8 +1,9 @@
|
||||
// Type definitions for @vimeo/player 2.0
|
||||
// Type definitions for @vimeo/player 2.6.3
|
||||
// Project: https://github.com/vimeo/player.js
|
||||
// Definitions by: Denis Yılmaz <https://github.com/denisyilmaz>
|
||||
// Felix Albert <f.albert.work@icloud.com>
|
||||
// Tim Chen <https://github.com/timc13>
|
||||
// Terry Mun <https://github.com/terrymun>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function myMethod(a: string): string;
|
||||
@@ -22,7 +23,8 @@ export interface InvalidCuePoint extends Error {name: "InvalidCuePoint"; message
|
||||
export interface RangeError extends Error {name: "RangeError"; message: string; method: string; }
|
||||
export interface TypeError extends Error {name: "TypeError"; message: string; method: string; }
|
||||
|
||||
export type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" | "cuechange" | "cuepoint" | "volumechange" | "error" | "loaded" | string;
|
||||
export type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" |
|
||||
"cuechange" | "cuepoint" | "volumechange" | "playbackratechange" | "bufferstart" | "bufferend" | "error" | "loaded" | string;
|
||||
export type EventCallback = (data: any) => any;
|
||||
|
||||
export class Player {
|
||||
@@ -51,6 +53,8 @@ export class Player {
|
||||
getLoop(): VimeoPromise<boolean, Error>;
|
||||
setLoop(loop: boolean): VimeoPromise<boolean, Error>;
|
||||
getPaused(): VimeoPromise<boolean, Error>;
|
||||
getPlaybackRate(): VimeoPromise<number, Error>;
|
||||
setPlaybackRate(playbackRate: number): VimeoPromise<number, Error>;
|
||||
getTextTracks(): VimeoPromise<VimeoTextTrack[], Error>;
|
||||
getVideoEmbedCode(): VimeoPromise<string, Error>;
|
||||
getVideoId(): VimeoPromise<number, Error>;
|
||||
@@ -85,14 +89,20 @@ export interface Options {
|
||||
url?: string;
|
||||
autopause?: boolean;
|
||||
autoplay?: boolean;
|
||||
background?: boolean;
|
||||
byline?: boolean;
|
||||
color?: string;
|
||||
height?: number;
|
||||
loop?: boolean;
|
||||
maxheight?: number;
|
||||
maxwidth?: number;
|
||||
muted?: boolean;
|
||||
playsinline?: boolean;
|
||||
portrait?: boolean;
|
||||
responsive?: boolean;
|
||||
speed?: boolean;
|
||||
title?: boolean;
|
||||
transparent?: boolean;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,21 @@ let player: Player ;
|
||||
|
||||
player = new Player('handstick', {
|
||||
id: 19231868,
|
||||
width: 640
|
||||
width: 640,
|
||||
|
||||
// Use default values for settings, to test typings
|
||||
autopause: true,
|
||||
autoplay: false,
|
||||
background: false,
|
||||
byline: true,
|
||||
color: '#00adef',
|
||||
loop: false,
|
||||
muted: false,
|
||||
playsinline: true,
|
||||
portrait: true,
|
||||
speed: false,
|
||||
title: true,
|
||||
transparent: true
|
||||
});
|
||||
|
||||
const onPlay = (data: any) => {
|
||||
@@ -281,12 +295,33 @@ player.getPaused().then((paused) => {
|
||||
// an error occurred
|
||||
});
|
||||
|
||||
player.getPlaybackRate().then((playbackRate) => {
|
||||
// playbackRate = a numeric value of the current playback rate
|
||||
}).catch((error) => {
|
||||
// an error occurred
|
||||
});
|
||||
|
||||
player.setPlaybackRate(0.5).then((playbackRate) => {
|
||||
// playback rate was set
|
||||
}).catch((error) => {
|
||||
switch (error.name) {
|
||||
case 'RangeError':
|
||||
// the playback rate was less than 0.5 or greater than 2
|
||||
break;
|
||||
|
||||
default:
|
||||
// some other error occurred
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
player.getTextTracks().then((tracks) => {
|
||||
// tracks = an array of track objects
|
||||
tracks.forEach((track) => {
|
||||
console.log(track.label);
|
||||
console.log(track.kind);
|
||||
console.log(track.language);
|
||||
console.log(track.mode);
|
||||
});
|
||||
}).catch((error) => {
|
||||
// an error occurred
|
||||
@@ -436,6 +471,19 @@ player.on('volumechange', (data) => {
|
||||
console.log(data.volume);
|
||||
});
|
||||
|
||||
player.on('playbackratechange', (data) => {
|
||||
// data is an object containing properties specific to that event
|
||||
console.log(data.playbackRate);
|
||||
});
|
||||
|
||||
player.on('bufferstart', (data) => {
|
||||
// no associated data with this event
|
||||
});
|
||||
|
||||
player.on('bufferend', (data) => {
|
||||
// no associated data with this event
|
||||
});
|
||||
|
||||
player.on('error', (data) => {
|
||||
// data is an object containing properties specific to that event
|
||||
console.log(data.message);
|
||||
|
||||
Reference in New Issue
Block a user