jiker-tcplayer
Version:
tcplayer in Jiker
116 lines (108 loc) • 3.18 kB
TypeScript
declare var tcplayer: {
(id: string, options?: tcplayer.ITCPlayerOptions): tcplayer.TCPlayer;
}
declare namespace tcplayer {
// listen type
type ListenType = 'play' | 'playing' | 'loadstart' | 'durationchange' | 'loadedmetadata' | 'loadeddata' | 'progress' | 'canplay' | 'canplaythrough' | 'error' | 'pause' | 'ratechange' | 'seeked' | 'seeking' | 'timeupdate' | 'volumechange' | 'waiting' | 'ended' | 'resolutionswitching' | 'resolutionswitched' | 'fullscreenchange' | 'webrtcevent' | 'webrtcstats';
// source 对象
interface ITCPlayerSourceItem {
src?: string;
type?: string;
}
// controlBar参数
interface ITCPlayerControlBar {
playToggle?: boolean;
progressControl?: boolean;
volumePanel?: boolean;
currentTimeDisplay?: boolean;
durationDisplay?: boolean;
timeDivider?: boolean;
playbackRateMenuButton?: boolean;
fullscreenToggle?: boolean;
QualitySwitcherMenuButton?: boolean;
}
// plugins参数
interface ITCPlayerPlugin {
ContinuePlay?: {
auto?: boolean;
text?: string;
btnText?: string;
};
VttThumbnail?: {
vttUrl?: string;
basePath?: string;
imgUrl?: string
};
ProgressMarker?: boolean;
DynamicWatermark?: {
content?: string;
speed?: number;
};
ContextMenu?: {
mirror?: boolean;
statistic?: boolean;
levelSwitch?: Record<string, any>;
}
}
// webrtcConfig参数
interface ITCPlayerWebrtcConfig {
connectRetryCount?: number;
connectRetryDelay?: number;
receiveVideo?: boolean;
receiveAudio?: boolean;
showLog?: boolean;
}
// hlsConfig参数
interface ITCPlayerHlsConfig {
[key: string]: any
}
// options参数
interface ITCPlayerOptions {
appID?: string;
fileID?: string;
sources?: Array<ITCPlayerSourceItem>;
width?: string | number;
height?: string | number;
controls?: boolean;
poster?: string;
autoplay?: boolean;
playbackRates?: Array<0.5 | 1 | 1.25 | 1.5 | 2>;
loop?: boolean;
muted?: boolean;
preload?: 'auto'|'meta'|'none';
swf?: string;
posterImage?: boolean;
bigPlayButton?: boolean;
language?: string;
languages?: Record<string, any>;
controlBar?: ITCPlayerControlBar;
reportable?: boolean;
plugins?: ITCPlayerPlugin;
hlsConfig?: ITCPlayerHlsConfig;
webrtcConfig?: ITCPlayerControlBar;
}
interface TCPlayer {
src: (url: string) => void;
ready: (cb: () => void) => void;
play: () => void;
pause: () => void;
currentTime: (seconds: number) => void;
duration: () => void;
volume: (percent: number) => void;
poster: (src: string) => void;
requestFullscreen: () => void;
exitFullscreen: () => void;
isFullscreen: () => void;
on: (type: ListenType, listener: () => void) => void;
one: (type: ListenType, listener: () => void) => void;
off: (type: ListenType, listener: () => void) => void;
buffered: () => void;
bufferedPercent: () => void;
width: () => void;
height: () => void;
videoWidth: () => void;
videoHeight: () => void;
dispose: () => void;
}
}
export = tcplayer;