Skip to content

Instantly share code, notes, and snippets.

@Reqwey
Last active March 16, 2024 09:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reqwey/62017d0581ec3aeae885928f19e19030 to your computer and use it in GitHub Desktop.
Save Reqwey/62017d0581ec3aeae885928f19e19030 to your computer and use it in GitHub Desktop.
Type Declaration for DIYgod/DPlayer, generated by GPT
declare module 'dplayer' {
interface DPlayerOptions {
container: HTMLElement;
autoplay?: boolean;
theme?: string;
loop?: boolean;
lang?: string;
screenshot?: boolean;
hotkey?: boolean;
preload?: string;
logo?: string;
volume?: number;
mutex?: boolean;
video: {
url: string;
pic?: string;
thumbnails?: string;
type?: string;
customType?: {
[type: string]: (video: HTMLVideoElement, player: DPlayer) => void;
};
};
subtitle?: {
url: string;
type?: string;
fontSize?: string;
bottom?: string;
color?: string;
};
// more options...
}
interface DPlayerEvents {
play?: () => void;
pause?: () => void;
canplay?: () => void;
playing?: () => void;
ended?: () => void;
error?: () => void;
// more events...
}
class DPlayer {
constructor(options: DPlayerOptions);
play(): void;
pause(): void;
seek(time: number): void;
volume(percentage: number): void;
switchVideo(video: { url: string; type?: string; }, thumbnail?: string): void;
on(event: string, handler: () => void): void;
off(event: string, handler: () => void): void;
destroy(): void;
// more methods...
}
export default DPlayer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment