|
| 1 | +// Type definitions for @vimeo/player 2.0 |
| 2 | +// Project: https://github.com/vimeo/player.js |
| 3 | +// Definitions by: Denis Yılmaz <https://github.com/denisyilmaz>, Felix Albert <f.albert.work@icloud.com> |
| 4 | +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
| 5 | +// tslint:disable-next-line no-single-declare-module |
| 6 | +declare module "@vimeo/player" { |
| 7 | + function myMethod(a: string): string; |
| 8 | + function myOtherMethod(a: number): number; |
| 9 | + |
| 10 | + type CallbackFunction = (...args: any[]) => any; |
| 11 | + |
| 12 | + interface Error {name: string; message: string; method: string; } |
| 13 | + |
| 14 | + interface PasswordError extends Error {name: "PasswordError"; message: string; method: string; } |
| 15 | + interface PrivacyError extends Error {name: "PrivacyError"; message: string; method: string; } |
| 16 | + interface InvalidTrackLanguageError extends Error {name: "InvalidTrackLanguageError"; message: string; method: string; } |
| 17 | + interface InvalidTrackError extends Error {name: "InvalidTrackError"; message: string; method: string; } |
| 18 | + interface UnsupportedError extends Error {name: "UnsupportedError"; message: string; method: string; } |
| 19 | + interface ContrastError extends Error {name: "ContrastError"; message: string; method: string; } |
| 20 | + interface InvalidCuePoint extends Error {name: "InvalidCuePoint"; message: string; method: string; } |
| 21 | + interface RangeError extends Error {name: "RangeError"; message: string; method: string; } |
| 22 | + interface TypeError extends Error {name: "TypeError"; message: string; method: string; } |
| 23 | + |
| 24 | + type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" | "cuechange" | "cuepoint" | "volumechange" | "error" | "loaded" | string; |
| 25 | + type EventCallback = (data: any) => any; |
| 26 | + |
| 27 | + class Player { |
| 28 | + constructor(element: HTMLIFrameElement|HTMLElement|string, options: Options); |
| 29 | + |
| 30 | + on(event: EventName, callback: EventCallback): void; |
| 31 | + off(event: EventName, callback?: EventCallback): void; |
| 32 | + loadVideo(id: number): VimeoPromise<number, TypeError | PasswordError | PrivacyError | Error>; |
| 33 | + ready(): VimeoPromise<void, Error>; |
| 34 | + enableTextTrack(language: string, kind?: string): VimeoPromise<VimeoTextTrack, InvalidTrackLanguageError | InvalidTrackError | Error>; |
| 35 | + disableTextTrack(): VimeoPromise<void, Error>; |
| 36 | + pause(): VimeoPromise<void, PasswordError | PrivacyError |Error>; |
| 37 | + play(): VimeoPromise<void, PasswordError | PrivacyError |Error>; |
| 38 | + unload(): VimeoPromise<void, Error>; |
| 39 | + getAutopause(): VimeoPromise<boolean, UnsupportedError | Error>; |
| 40 | + setAutopause(autopause: boolean): VimeoPromise<boolean, UnsupportedError | Error>; |
| 41 | + getColor(): VimeoPromise<string, Error>; |
| 42 | + setColor(color: string): VimeoPromise<string, ContrastError | TypeError | Error>; |
| 43 | + addCuePoint(time: number, data: VimeoCuePointData): VimeoPromise<string, UnsupportedError | RangeError | Error>; |
| 44 | + removeCuePoint(id: string): VimeoPromise<string, UnsupportedError | InvalidCuePoint | Error>; |
| 45 | + getCuePoints(): VimeoPromise<VimeoCuePoint[], UnsupportedError | Error>; |
| 46 | + getCurrentTime(): VimeoPromise<number, Error>; |
| 47 | + setCurrentTime(seconds: number): VimeoPromise<number, RangeError | Error>; |
| 48 | + getDuration(): VimeoPromise<number, Error>; |
| 49 | + getEnded(): VimeoPromise<boolean, Error>; |
| 50 | + getLoop(): VimeoPromise<boolean, Error>; |
| 51 | + setLoop(loop: boolean): VimeoPromise<boolean, Error>; |
| 52 | + getPaused(): VimeoPromise<boolean, Error>; |
| 53 | + getTextTracks(): VimeoPromise<VimeoTextTrack[], Error>; |
| 54 | + getVideoEmbedCode(): VimeoPromise<string, Error>; |
| 55 | + getVideoId(): VimeoPromise<number, Error>; |
| 56 | + getVideoTitle(): VimeoPromise<string, Error>; |
| 57 | + getVideoWidth(): VimeoPromise<number, Error>; |
| 58 | + getVideoHeight(): VimeoPromise<number, Error>; |
| 59 | + getVideoUrl(): VimeoPromise<string, PrivacyError | Error>; |
| 60 | + getVolume(): VimeoPromise<number, Error>; |
| 61 | + setVolume(volume: number): VimeoPromise<number, RangeError | Error>; |
| 62 | + } |
| 63 | + |
| 64 | + interface VimeoCuePoint { |
| 65 | + time: number; |
| 66 | + data: VimeoCuePointData; |
| 67 | + id: string; |
| 68 | + } |
| 69 | + |
| 70 | + interface VimeoCuePointData extends Object { |
| 71 | + customKey: string; |
| 72 | + } |
| 73 | + |
| 74 | + interface VimeoTextTrack { |
| 75 | + language: string; |
| 76 | + kind: string; |
| 77 | + label: string; |
| 78 | + mode?: string; |
| 79 | + } |
| 80 | + |
| 81 | + interface Options { |
| 82 | + id?: number; |
| 83 | + url?: string; |
| 84 | + autopause?: boolean; |
| 85 | + autoplay?: boolean; |
| 86 | + byline?: boolean; |
| 87 | + color?: string; |
| 88 | + height?: number; |
| 89 | + loop?: boolean; |
| 90 | + maxheight?: number; |
| 91 | + maxwidth?: number; |
| 92 | + portrait?: boolean; |
| 93 | + title?: boolean; |
| 94 | + width?: number; |
| 95 | + } |
| 96 | + |
| 97 | + interface VimeoPromise<Result, Reason> extends Promise<Result> { |
| 98 | + ( |
| 99 | + successCallback?: (promiseValue: Result) => void, |
| 100 | + rejectCallback?: (reasonValue: Reason) => void |
| 101 | + ): Promise<Result>; |
| 102 | + } |
| 103 | + |
| 104 | + /*~ You can declare properties of the module using const, let, or var */ |
| 105 | + const playerMap: WeakMap<any, any>; |
| 106 | + const readyMap: WeakMap<any, any>; |
| 107 | +} |
0 commit comments