@kwai-video-team/kwai-player-web
Version:
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4,089 lines • 115 kB
TypeScript
import { EventEmitter } from 'events';
/**
* @public
*/
declare type AACPrivPayload = {
id: number;
checkSum: number;
data: Uint8Array;
};
/**
* @public
*/
declare type AACPrivReportData = {
payload: AACPrivPayload[];
/** 流时间,ms */
streamTimestamp?: number;
/** 播放时间,ms */
time?: number;
} & SampleExtraDataBasic;
/**
* @public
*/
declare type AbrConfig = {
defaultSpts: number;
bitrate?: number;
liveAdaptiveConfig?: LiveAdaptiveConfig;
hlsAdaptiveConfig?: HlsAdaptiveConfig;
abrSpeedTest: boolean;
liveShiftDelaySec: number;
liveDelayFragNum: number;
};
/**
* @public
*/
declare class AbstractDestroyable implements IDestroyable {
/* Excluded from this release type: _destroyableList */
destroy(): void;
}
export declare type ActionOnReady = 'play' | 'pause';
/**
* @public
*/
declare type AudioTrackInfo = {
lang?: string;
qualityLabel: string;
qualityType: string;
bitrate: number;
groupId: string;
};
/**
* @public
*/
declare type AutoPlaybackRateConfig = {
startDelay: number;
interval: number;
rule: {
rate: number;
lower: number;
upper: number;
}[];
};
/**
* Chromaticity coordinates of the source primaries.
* These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
* @public
*/
declare enum AVColorPrimaries {
AVCOL_PRI_RESERVED0 = 0,
AVCOL_PRI_BT709 = 1,// /< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
AVCOL_PRI_UNSPECIFIED = 2,
AVCOL_PRI_RESERVED = 3,
AVCOL_PRI_BT470M = 4,// /< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVCOL_PRI_BT470BG = 5,// /< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
AVCOL_PRI_SMPTE170M = 6,// /< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
AVCOL_PRI_SMPTE240M = 7,// /< functionally identical to above
AVCOL_PRI_FILM = 8,// /< colour filters using Illuminant C
AVCOL_PRI_BT2020 = 9,// /< ITU-R BT2020
AVCOL_PRI_SMPTE428 = 10,// /< SMPTE ST 428-1 (CIE 1931 XYZ)
AVCOL_PRI_SMPTEST428_1 = 10,
AVCOL_PRI_SMPTE431 = 11,// /< SMPTE ST 431-2 (2011) / DCI P3
AVCOL_PRI_SMPTE432 = 12,// /< SMPTE ST 432-1 (2010) / P3 D65 / Display P3
AVCOL_PRI_EBU3213 = 22,// /< EBU Tech. 3213-E / JEDEC P22 phosphors
AVCOL_PRI_JEDEC_P22 = 22,
AVCOL_PRI_NB = 23
}
/**
* @public
*/
declare enum AVColorRange {
AVCOL_RANGE_UNSPECIFIED = 0,
AVCOL_RANGE_MPEG = 1,
AVCOL_RANGE_JPEG = 2
}
/**
* YUV colorspace type.
* These values match the ones defined by ISO/IEC 23001-8_2013 § 7.3.
* @public
*/
declare enum AVColorSpace {
AVCOL_SPC_RGB = 0,// /< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
AVCOL_SPC_BT709 = 1,// /< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVCOL_SPC_UNSPECIFIED = 2,
AVCOL_SPC_RESERVED = 3,
AVCOL_SPC_FCC = 4,// /< FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVCOL_SPC_BT470BG = 5,// /< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVCOL_SPC_SMPTE170M = 6,// /< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
AVCOL_SPC_SMPTE240M = 7,// /< functionally identical to above
AVCOL_SPC_YCGCO = 8,// /< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
AVCOL_SPC_YCOCG = 8,
AVCOL_SPC_BT2020_NCL = 9,// /< ITU-R BT2020 non-constant luminance system
AVCOL_SPC_BT2020_CL = 10,// /< ITU-R BT2020 constant luminance system
AVCOL_SPC_SMPTE2085 = 11,// /< SMPTE 2085, Y'D'zD'x
AVCOL_SPC_CHROMA_DERIVED_NCL = 12,// /< Chromaticity-derived non-constant luminance system
AVCOL_SPC_CHROMA_DERIVED_CL = 13,// /< Chromaticity-derived constant luminance system
AVCOL_SPC_ICTCP = 14,// /< ITU-R BT.2100-0, ICtCp
AVCOL_SPC_NB = 15
}
/**
* Color Transfer Characteristic.
* These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2.
* @public
*/
declare enum AVColorTransferCharacteristic {
AVCOL_TRC_RESERVED0 = 0,
AVCOL_TRC_BT709 = 1,// /< also ITU-R BT1361
AVCOL_TRC_UNSPECIFIED = 2,
AVCOL_TRC_RESERVED = 3,
AVCOL_TRC_GAMMA22 = 4,// /< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
AVCOL_TRC_GAMMA28 = 5,// /< also ITU-R BT470BG
AVCOL_TRC_SMPTE170M = 6,// /< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
AVCOL_TRC_SMPTE240M = 7,
AVCOL_TRC_LINEAR = 8,// /< "Linear transfer characteristics"
AVCOL_TRC_LOG = 9,// /< "Logarithmic transfer characteristic (100:1 range)"
AVCOL_TRC_LOG_SQRT = 10,// /< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
AVCOL_TRC_IEC61966_2_4 = 11,// /< IEC 61966-2-4
AVCOL_TRC_BT1361_ECG = 12,// /< ITU-R BT1361 Extended Colour Gamut
AVCOL_TRC_IEC61966_2_1 = 13,// /< IEC 61966-2-1 (sRGB or sYCC)
AVCOL_TRC_BT2020_10 = 14,// /< ITU-R BT2020 for 10-bit system
AVCOL_TRC_BT2020_12 = 15,// /< ITU-R BT2020 for 12-bit system
AVCOL_TRC_SMPTE2084 = 16,// /< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
AVCOL_TRC_SMPTEST2084 = 16,
AVCOL_TRC_SMPTE428 = 17,// /< SMPTE ST 428-1
AVCOL_TRC_SMPTEST428_1 = 17,
AVCOL_TRC_ARIB_STD_B67 = 18,// /< ARIB STD-B67, known as "Hybrid log-gamma"
AVCOL_TRC_NB = 19
}
/**
* @public
*/
declare type BaseConfig = {
isLive?: boolean;
box?: MediaBox;
src?: InputMediaDescription;
nativeFirst?: boolean;
credentials: boolean;
startPlayBufferSec: number;
adaptive: boolean;
startFrom?: number;
startFromKeyframe: boolean;
resourceBuffer: boolean;
resourceBufferSize: number;
baseURL?: string;
appendErrorMaxRetry: number;
alwaysSeekKeyframe: boolean;
liveShiftType: LiveShiftType_2;
forceRenderOnSeekEnd?: boolean;
playbackAbilityCacheTimeout: number;
} & LiveConfig & LoadConfig & LogConfig;
/**
* @public
*/
declare type BaseLevelEventData = {
level: number;
};
/**
* @public
*/
declare type BaseLoaderConfig = {
preprocessUrl?: PreprocessURL;
preferNativeLoader?: boolean;
};
/**
* 基础媒体描述,可以输入url、File或者快手私有Manifest
* @public
*/
declare type BaseMediaDescription = string | Blob | KwaiManifest | FlvAbrManifest | FlvMultipartManifest | HLSManifest;
/**
* @public
*/
declare type BaseSEIPayload = {
type: number;
data: Uint8Array;
};
/**
* @public
*/
declare type BasicEventData = {
/* Excluded from this release type: preventFollowUp */
};
/**
* @public
*/
export declare type BizData = {
resourceId?: string | number;
userId?: string | number;
photoId?: string;
activityTag?: string;
request?: {
header: Record<string, any>;
};
secretId?: string;
secretKey?: string;
isVip?: boolean | number;
} & Record<string, unknown>;
export declare class CallbackProxy {
private _callbacks;
add(cb: (params: unknown) => void): void;
remove(cb: (params: unknown) => void): void;
call(params: unknown): void;
destroy(): void;
}
/**
* @public
*/
declare enum CanvasContextType {
/**
* HDR渲染颜色不对,已知问题。
*/
canvas2d = "canvas2d",
webgl = "webgl"
}
/**
* @public
*/
declare enum CodecType {
unknown = "unknown",
h264 = "h264",
hevc = "hevc",
av1 = "av1",
kvc3 = "kvc3",
kvc4 = "kvc4",
kvc5 = "kvc5",
kvc6 = "kvc6",
aac = "aac",
mp3 = "mp3",
opus = "opus",
yuv = "yuv",
rawvideo = "rawvideo",
vvc = "vvc",
bvc2 = "bvc2",
kvc30 = "kvc30"
}
/**
* @public
*/
declare type ColorInfo = {
colorRange: AVColorRange;
colourPrimaries: AVColorPrimaries;
transferCharacteristics: AVColorTransferCharacteristic;
matrixCoefficients: AVColorSpace;
};
/**
* @public
* 控制条的多语言key
*/
export declare enum ControlsLangDictKey {
PLAY = "play",
PAUSE = "pause",
REFRESH = "refresh",
NEXT = "next",
TURN_ON_LOOP = "turnOnLoop",
TURN_OFF_LOOP = "turnOffLoop",
LOOP = "loop",
PLAYBACK_RATE_NORMAL = "playbackRateNromal",
OPTIONS = "options",
DOWNLOAD = "download",
VIDEO_TRACK = "videoTrack",
AUDIO_TRACK = "audioTrack",
PLAYBACK_RATE = "playbackRate",
PLAYBACK_RATE_SHORT = "playbackRateShort",
PICTURE_IN_PICTURE = "pictureInPicture",
EXIT_PICTURE_IN_PICTURE = "exitPictureInPicture",
PLAY_INFO = "playInfo",
MIRROR_IMAGE = "mirrorImage",
ROTATE = "rotate",
FULLSCREEN = "fullscreen",
EXIT_FULLSCREEN = "exitFullscreen",
WINDOW_FULLSCREEN = "windowFullscreen",
EXIT_WINDOW_FULLSCREEN = "exitWindowFullscreen",
AUTO = "auto",
CURRENT_VOLUME = "currentVolume",
CURRENTLY_MUTED = "currentlyMuted",
SWITCH_TO_VIDEO = "switchToVideo",
SWITCHING_TO_VIDEO = "switchingToVideo",
SWITCHED_TO_VIDEO = "switchedToVideo",
SWITCH_TO_AUDIO = "switchToAudio",
SWITCHING_TO_AUDIO = "switchingToAudio",
SWITCHED_TO_AUDIO = "switchedToAudio",
FAIL = "fail",
ERROR_PANEL_TITLE = "errorPanelTitle",
ERROR_PANEL_RETRY_BTN = "errorPanelRetryBtn",
LIVE = "live",
RETURN_TO_LIVE = "returnToLive"
}
/**
* @public
*/
export declare type ControlsModuleOption = {
danmakuControlsPos?: DanmakuControlsPos;
danmakuControlsPosFullscreen?: DanmakuControlsPos;
} & Record<string, unknown>;
/**
* @public
*/
export declare const ControlsPluginLabel = "ControlsPlugin";
/**
* @public
* 播放控件插件定义
*/
export declare abstract class ControlsPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
beforeInstall(_player: IKwaiPlayer, _options?: ControlsModuleOption): void;
afterInstall(_player: IKwaiPlayer, _options?: ControlsModuleOption): void;
abstract readonly container: HTMLDivElement | undefined;
}
export declare enum ControlsSlotPos {
PLAY_BAR_LEFT = "playBarLeft",
PLAY_BAR_RIGHT = "playBarRight",
CONTEXT_MENU = "contextMenu"
}
export declare type ControlsSoltSvgBtn = {
role: string;
slotPos: ControlsSlotPos | string;
svgRaw?: string;
callback?: CallbackProxy;
getTips?: () => string;
getChecked?: () => boolean;
getText?: () => string;
onClick: () => void;
};
/**
* @public
*/
export declare enum DanmakuControlsPos {
BOTTOM = "bottom",
PLAY_BAR = "playBar",
NONE = "none"
}
/**
* @public
*/
export declare enum DanmakuPluginDomStyle {
DARK = "dark",
LIGHT = "light"
}
/**
* @public
*/
export declare const DanmakuPluginLabel = "DanmakuPlugin";
/**
* @public
*/
export declare abstract class DanmakuPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
/**
* 是否渲染
*/
abstract rendering: boolean;
/**
* 信息Dom
*/
abstract getInfoDom(style?: DanmakuPluginDomStyle | string): HTMLElement | undefined;
/**
* 控制面板
*/
abstract getControlPanelDom(style?: DanmakuPluginDomStyle | string): HTMLElement | undefined;
}
/**
* @public
*/
declare type DecConfig = {
videoDropFramePolicy: VideoDropFramePolicy;
videoFrameBufferSize: number;
videoDecBlockPolicy: VideoDecBlockPolicy;
maxVideoDecThreads: number;
mainThreadDecoding: boolean;
} & RendererConfig & LogConfig;
/**
* @public
*/
declare type DecLibLoaderConfig = {
decLibLoadingMaxRetry: number;
decLibConnectionTimeout: number;
decLibLoadingRetryDelay: number;
} & BaseLoaderConfig;
/**
* @public
*/
declare enum Decoder {
buildin = "buildin",
wasm = "wasm",
none = "none",
unsupported = "unsupported"
}
/**
* @public
*/
declare type DecrypterConfig = {
enableSoftwareAES: boolean;
};
/**
* @public
*/
declare type DiscontinuityEventData = {
streamTimestamp: number;
};
/**
* @public
*/
declare type DownloadInfo = {
domain: string;
stream_host: string;
download_url: string;
response_url?: string;
download_start_time: number;
download_spend_time: number;
download_status: DownloadStatus;
http_status_code: number;
retry_index: number;
error_code: number;
error_message: string;
loader_id: string;
download_size: number;
resource_type: string;
slice_play_start_time?: number;
slice_play_duration?: number;
slice_index?: number | 'initSegment';
slice_level_index?: number;
quality_type?: string;
range_start?: number;
range_end?: number;
codec?: string;
transcoding_template?: string;
http_response_time: number;
response_header?: string[];
redirect?: number;
time_redirect?: number;
time_dns?: number;
time_tcp?: number;
time_request?: number;
time_first_response?: number;
time_response?: number;
duration?: number;
monkey_patched?: number;
use_reset_native_fetch?: number;
};
/**
* REPORT事件 type === DOWNLOAD 数据
* @public
*/
declare type DownloadReportData = {
session_id: string;
kernel_version: string;
load_start_time: number;
use_backup: number;
first_screen: number;
} & DownloadInfo;
/**
* @public
*/
declare enum DownloadStatus {
FAIL = "FAIL",
ABORT = "ABORT",
SUCCESS = "SUCCESS",
CONNECTED = "CONNECTED"
}
/**
* @public
*/
declare enum ErrorDetails {
LOAD_ERROR = 10,
MANIFEST_LOAD_ERROR = 11,// HLS manifest加载错误
LEVEL_LOAD_ERROR = 12,
AUDIO_TRACK_LOAD_ERROR = 13,
KEY_LOAD_ERROR = 14,
KEY_SYSTEM_LICENSE_REQUEST_FAILED = 15,
DEC_LIB_LOAD_ERROR = 16,
RTC_SDP_LOAD_ERROR = 17,
SUBTITLE_TRACK_LOAD_ERROR = 18,
CANNOT_SEEK = 100,
VIDEO_ERROR = 101,
UNSUPPORTED = 102,
CONFIG_ERROR = 103,
OTHER = 104,
UNKNOWN = 105,
CANNOT_SEEK_BY_FRAME_INDEX = 106,
SRC_EMPTY = 107,
VIDEO_NO_SIZE = 108,
NO_TRACKS_AVAILABLE = 109,
VIDEO_ERROR_1 = 111,
VIDEO_ERROR_2 = 112,
VIDEO_ERROR_3 = 113,
VIDEO_ERROR_4 = 114,
MEDIASOURCE_ERROR = 200,// mediaSourceError 初始化MSE错误,MediaSource未定义时触发
ADDSOURCEBUFFER_ERROR = 201,// addSourceBufferError MSE增加SourceBuffer失败
SOURCEBUFFER_ERROR = 202,// sourceBufferError MSE的SourceBuffer触发错误
ENDOFSTREAM_ERROR = 203,// endOfStreamError MSE结束流错误
APPENDBUFFER_ERROR = 204,// appendBufferError MSE填充buffer错误
CHANGETYPE_ERROR = 205,// changeTypeError SourceBuffer changeType 错误
MSE_CAPABILITY_ERROR = 206,
MSE_SOURCE_BUFFER_CLOSE_ERROR = 207,// mse 异常关闭
PARSING_ERROR = 301,// 解封装错误
REMUX_ERROR = 302,// 重新封装错误
REMUX_ALLOC_ERROR = 303,// 重新封装alloc mdat存储错误
REMUX_WORKER_ERROR = 304,// remux worker报错
DEMUX_NOT_FOUND = 305,// 未找到解封装器
MANIFEST_PARSING_ERROR = 400,
LEVEL_NO_UPDATE_ERROR = 402,
KEY_SYSTEM_NO_ACCESS = 500,
KEY_SYSTEM_NO_SESSION = 501,
KEY_SYSTEM_URL_ERROR = 502,
KEY_SYSTEM_NO_KEYS = 505,
FRAG_DECRYPT_ERROR = 506,
KEY_SYSTEM_NO_INIT_DATA = 507,
KEY_SYSTEM_UNSUPPORTED = 508,
DECODER_LOAD_ERROR = 600,
DECODER_INIT_ERROR = 601,
DECODER_DRAW_ERROR = 602,
DECODER_WEBGL_ERROR = 603,
DECODER_UNSUPPORTED = 604,
DECODER_COPY_YUV_ERROR = 605,
DECODER_DEC_ERROR = 606,
DECODER_2D_ERROR = 607,
SCREENSHOT_INIT_ERROR = 700,
SCREENSHOT_EMPTY_DATA_ERROR = 701,
SCREENSHOT_CREATE_IMG_ERROR = 702,
LIVE_DISCONNECTED_ERROR = 1009,// 直播连接中断
WEBRTC_DISCONNECTED_ERROR = 1010,// webrtc DISCONNECTED
WEBRTC_FAILED_ERROR = 1011,// webrtc FAILED
WEBRTC_CLOSED_ERROR = 1012,// webrtc CLOSED
WEBRTC_ICE_CANDIDATE_ERROR = 1013,// ice协商相关错误
WEBRTC_ICE_CONNECTION_ERROR = 1014,// pc连接错误
WEBRTC_OFFER_ERROR = 1015,// 设置或Offer相关错误
WEBRTC_ANSWER_ERROR = 1016,// 设置或Answer相关错误
WEBRTC_TRANSMISSION_DATA_NULL = 1017,// 传输数据为空
WEBRTC_CONNECT_TIMEOUT = 1018,// webrtc 连接超时
WEBRTC_CONNECT_FAILED = 1019
}
/**
* @public
*/
declare type ErrorEventData = {
type: ErrorTypes;
details: ErrorDetails;
code: number;
fatal: boolean;
reason: string;
statusCode?: number;
url?: string;
} & BasicEventData;
/**
* @public
*/
export declare type ErrorMsg = {
code: number;
message: string;
};
/**
* @public
*/
declare enum ErrorTypes {
NETWORK_ERROR = "networkError",
MEDIA_ERROR = "mediaError",
KEY_SYSTEM_ERROR = "keySystemError",
MUX_ERROR = "muxError",
OTHER_ERROR = "otherError",
MSE_ERROR = "mseError",
DECODER_ERROR = "decoderError",
RENDERER_ERROR = "rendererError"
}
/** @public */
declare type ExposedEvents = Pick<typeof KEvents, 'REPORT' | 'ERROR' | 'LEVEL_SWITCHING' | 'LEVEL_SWITCHED' | 'LEVEL_SWITCH_PLAYING' | 'LEVEL_SWITCH_FAILED' | 'AUDIO_TRACK_SWITCHING' | 'AUDIO_TRACK_SWITCHED' | 'AUDIO_TRACK_UPDATED' | 'SUBTITLE_TRACK_SWITCHED' | 'MANIFEST_PARSED' | 'LEVEL_UPDATED' | 'LOAD_END' | 'VIDEO_RENDERER_CHANGE' | 'SCREENSHOT'>;
/**
* @public
*/
declare type FlvAbrAdaptationSet = {
gopDuration?: number;
representation: FlvAbrRepresentation[];
} & Record<string, unknown>;
/**
* @public
*/
declare type FlvAbrManifest = {
version: string;
hideAuto?: boolean;
adaptationSet: FlvAbrAdaptationSet;
} & Record<string, unknown>;
/**
* @public
*/
declare type FlvAbrRepresentation = {
id?: number;
url: string;
name: string;
bitrate: number;
qualityType: string;
codec?: string;
averageBitrate?: number;
hidden?: boolean;
enableAdaptive?: boolean;
defaultSelect?: boolean;
mediaType?: string;
level?: number;
} & Record<string, unknown>;
/**
* @public
*/
declare type FlvMultipartManifest = {
type: string;
duration: number;
withCredentials: boolean;
hasAudio?: boolean;
hasVideo?: boolean;
segments: FlvMultipartSegment[];
} & Record<string, unknown>;
/**
* @public
*/
declare type FlvMultipartSegment = {
url: string;
periodId: number | string;
time?: number;
duration?: number | string;
filesize?: number;
startUtcTime?: number | string;
} & Record<string, unknown>;
export declare type FullScreenDirection = 'portrait' | 'right' | 'left';
/**
* @public
*/
export declare type FullscreenEventData = {
type: FullscreenType;
isFull: boolean;
};
/**
* @public
*/
export declare enum FullscreenType {
SYSTEM = "system",
WINDOW = "window"
}
/**
* @public
* @deprecated 对应事件已弃用
*/
declare type H265DetectedEventData = {
canvas?: HTMLCanvasElement;
message: string;
enabled: boolean;
decoder: Decoder;
};
/**
* REPORT事件 type === HEARTBEAT 数据
* @public
*/
declare type HeartbeatReportData = {
/**
* 数据下载量:单位:B
*/
totalReceive?: number;
/**
* 当前下载速度,单位:B/s
*/
speed?: number;
/**
* 视频码率, 单位:Kb/s
*/
videoDataRate?: number;
/**
* 音频码率,单位:Kb/s
*/
audioDataRate?: number;
/**
* video缓冲区长度,单位:毫秒
*/
buffered?: number;
/**
* 视频轨缓冲区长度,单位:毫秒
*/
videoBuffered?: number;
/**
* 音频轨缓冲区长度,单位:毫秒
*/
audioBuffered?: number;
/**
* 解码fps
*/
decodedFPS?: number;
/**
* 丢帧fps
*/
droppedFPS?: number;
/**
* 解码帧
*/
decodedFrames?: number;
/**
* 丢帧
*/
droppedFrames?: number;
/**
* RTC直播
*/
audioAvgJitterBufferDelay?: number;
/**
* RTC直播
*/
videoAvgJitterBufferDelay?: number;
/**
* RTC直播
*/
audioPacketsLost?: number;
/**
* RTC直播
*/
videoPacketsLost?: number;
/**
* flv直播渲染延迟
*/
displayDelay?: number;
/**
* flv直播音频渲染延迟
*/
audioRenderDelay?: number;
/**
* flv直播,数据延迟
*/
recDelay?: number;
/**
* 填充视频空帧长度,单位:毫秒
*/
fillVideo?: number;
/**
* 填充音频空帧长度,单位:毫秒
*/
fillAudio?: number;
/**
* 收到的关键帧数量
*/
keyFrame?: number;
/**
* 懒加载下限
*/
lazyloadMin?: number;
/**
* 懒加载上限
*/
lazyloadMax?: number;
/**
* 是否处于直播时移状态
*/
liveShift?: boolean;
/**
* 当前流是否是直播
*/
isLive?: boolean;
/**
* wasm缓存长度
*/
wasmFrameBufLen?: number;
/**
* 当前播放时间,毫秒
*/
playPos?: number;
};
/**
* @public
*/
declare type HlsAdaptiveConfig = {
beacon: boolean;
predictStep: number;
targetBuffer: number;
duration: number;
smoothRatioToTarget: number;
switchpanelty: number;
slidingWindowSize: number;
kalmanR: number;
kalmanQ: number;
initBitrate: number;
startBitrateLimit: boolean;
speedPredictRatio: number;
speedPredictNum: number;
algorithm: number;
speedPredictRatioOnStart: number;
lowProfileThreshold: number;
lowProfileBitrate: number;
lowProfileStartThreshold: number;
};
/**
* @public
*/
declare type HLSManifest = {
version: string;
type: string;
adaptationSet: HLSManifestAdaptationSet;
} & Record<string, unknown>;
/**
* @public
*/
declare type HLSManifestAdaptationSet = {
representation: HLSManifestRepresentation[];
} & Record<string, unknown>;
/**
* @public
*/
declare type HLSManifestRepresentation = {
url: string;
backupUrl: string[];
baseUrl: string;
m3u8: string;
bandwidth: number;
averageBandwidth: number;
codecs: string;
width: number;
height: number;
frameRate: number;
m3u8Slice: string;
duration: number;
qualityType?: string;
qualityLabel?: string;
defaultSelect?: boolean;
} & Record<string, unknown>;
/**
* @public
*/
export declare const HotkeyPluginLabel = "HotkeyPlugin";
/**
* @public
*/
export declare abstract class HotkeyPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
readonly abstract disable: boolean;
}
/**
* @public
*/
declare enum HttpRangeType {
STANDARD = "standard",
QUERY_START_END = "queryStartEnd"
}
/**
* @public
*/
export declare const I18nPluginLabel = "I18nPlugin";
/**
* @public
* 多语言插件定义
*/
export declare abstract class I18nPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
beforeInstall(_player: IKwaiPlayer, _options?: I18nPluginModuleOption): void;
afterInstall(_player: IKwaiPlayer, _options?: I18nPluginModuleOption): void;
abstract text(pluginLabel: string, key: string): string;
abstract addDict(map: LangMap, lang?: string): void;
}
/**
* @public
*/
export declare type I18nPluginModuleOption = {
lang?: string;
langDict?: LangDict;
};
export declare interface IBaseContextEvent<T extends string = any, D = null> {
type: T;
data: D;
}
/**
* @public
*/
declare interface IDestroyable {
destroy(): void;
}
/**
* @public
*/
declare interface IKEventEmitter {
on<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
once<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
removeAllListeners<T extends keyof KernelEventMap>(event?: T): void;
off<T extends keyof KernelEventMap>(event: T, listener?: KernelEventMap[T]): void;
emit<T extends keyof KernelEventMap>(event: T, eventObject?: Parameters<KernelEventMap[T]>[0]): boolean;
listenerCount<T extends keyof KernelEventMap>(event: T): number;
}
/**
* @public
*/
export declare interface IKwaiPlayer extends IPlayerEventEmitter {
readonly packVersion: string;
readonly version: string;
readonly kernelType: KernelType;
readonly error: ErrorMsg | undefined;
/**
* 获取当前是否时移回放
*/
readonly isLiveShift: boolean;
/**
* 网络状态
*/
readonly networkState: number;
/**
* 获取预加载配置
*/
readonly buffered: TimeRanges | undefined;
/**
* 获取video元素readyState
*/
readonly readyState: number;
/**
* 获取video元素seeking状态
*/
readonly seeking: boolean;
/**
* 获取video时长
*/
readonly duration: number;
/**
* 获取暂停状态
*/
readonly paused: boolean;
/**
* 获取是否播放
*/
readonly played?: TimeRanges;
/**
* 获取是否可以seek
*/
readonly seekable?: TimeRanges;
/**
* 获取是否播放完成
*/
readonly ended: boolean;
/**
* 当前清晰度时间信息
*/
readonly currentLevelTimeInfo: LevelTimeInfo | undefined;
readonly video: HTMLVideoElement;
readonly canvas: HTMLCanvasElement | undefined;
readonly yodaDom: HTMLDivElement | undefined;
readonly kernel: KwaiPlayerKernel | undefined;
/**
* 获取主容器
*/
readonly mainContainer: HTMLElement | null | undefined;
readonly videoLayer: HTMLDivElement;
readonly videoInteractiveLayer: HTMLDivElement;
/**
* 获取当前QOS信息
*/
readonly audienceStat: unknown;
readonly objectFit?: string;
/**
* 设置内核配置
*/
config: Partial<KernelConfig> | undefined;
videoId: string | undefined;
previewUrl: string | undefined;
maskUrl: string | undefined;
disableMask: boolean | undefined;
/**
* 播放地址
*/
src: MediaDescription | unknown;
/**
* 直播时移类型
*/
liveShiftType: LiveShiftType;
/**
* 跨域
*/
crossOrigin: string | null;
/**
* 预加载 'none' | 'auto'
*/
preload: string;
/**
* video播放时间
*/
currentTime: number;
/**
* 默认倍速
*/
defaultPlaybackRate: number;
/**
* 当前倍速
*/
playbackRate: number;
/**
* 是否自动播放
*/
autoplay: boolean;
/**
* 是否循环播放
*/
loop: boolean;
/**
* 是否显示控制条
*/
controls: boolean | string;
/**
* 音量
*/
volume: number;
/**
* 静音
*/
muted: boolean;
/**
* 默认静音状态
*/
defaultMuted: boolean;
/**
* 视频宽
*/
videoWidth: number;
/**
* 视频高
*/
videoHeight: number;
/**
* 封面图
*/
poster: string;
/**
* 禁用画中画状态
*/
disablePictureInPicture: boolean;
disableDownload: boolean | undefined;
/**
* 内联(inline)播放
*/
playsinline: boolean;
/**
* 自适应码率开关状态
*/
disableAdaptive: boolean | undefined;
/**
* 当前视频轨id
*/
currentLevel: number;
/**
* 获取即将切换的视频轨id
*/
nextLevel: number;
/**
* 获取当前播放帧数
*/
currentVideoFrame: number;
/**
* 获取当前视频总帧数
*/
totalVideoFrames: number;
/**
* 当前音频轨id
*/
audioTrack: number;
productName: string | undefined;
/**
* 获取当前是否开启连接预热
*/
prefetch: boolean | undefined;
/**
* 获取是否显示进度条
* @remarks 依赖控制条插件
*/
showProgress: boolean | undefined;
/**
* 获取是否显示时间
* @remarks 依赖控制条插件
*/
showTime: boolean | undefined;
/**
* 获取是否启用热键
* @remarks 依赖热键插件
*/
disableHotkey: boolean | undefined;
/**
* 弹幕是否可用
*/
disableDanmaku: boolean | undefined;
danmakuRendering: boolean | undefined;
/**
* 设置是否显示信息面板
* @remarks 依赖信息面板插件
*/
showInfoPanel: boolean | undefined;
showNext: boolean | undefined;
showPrev: boolean | undefined;
bizData: BizData | undefined;
liveTime: LiveTime | undefined;
/**
* 实例id
*/
instanceId: number;
/**
* 本地日志实例
*/
logger: ILogger_2;
/**
* 本地日志输出
*/
outputLogger?: ILogger_2;
setPreprocessURL(val: PreprocessURL | undefined): void;
setPreprocessSrcFunc(val: PreprocessSrcFunc): void;
/**
* 加载视频
*/
load(): void;
/**
* 播放视频
*/
play(): Promise<void>;
/**
* 暂停视频
*/
pause(): void;
/**
* 开启画中画
*/
requestPictureInPicture(): Promise<PictureInPictureWindow>;
isPictureInPictureAvailable(): boolean;
/**
* 销毁播放器
*/
destroy(): void;
/**
* 重新加载视频
*/
refresh(): void;
/**
* 支持时移时回到直播状态
*/
jumpToLive(): void;
/**
* 根据插件名获取插件实例
* @param label 插件名
* @returns plugin
*/
getPluginInstance<pluginLabel extends keyof PluginMap>(label: string | pluginLabel): PluginMap[pluginLabel] | undefined;
/**
* 获取所有的插件实例
* @returns 所有的插件实例
*/
getAllPlugins(): PluginModule[];
/**
* 创建一个子容器
* @returns HTMLDivELement
*/
createSubContainer(layer?: KwaiPlayerLayer): HTMLDivElement;
/**
* 是否全屏
* @returns boolean
*/
isFullscreen(type?: FullscreenType): boolean;
/**
* 开启全屏
* @param type 'system' 系统全屏 'window' 网页全屏
* @returns
*/
requestFullscreen: (type?: FullscreenType) => void;
/**
* 退出全屏
* @param type 'system' 系统全屏 'window' 网页全屏
* @returns
*/
exitFullscreen: (type?: FullscreenType) => void;
isFullscreenAvailable(type?: FullscreenType): boolean;
removeSubContainer(container: HTMLDivElement): void;
/**
* 截图
*/
screenshot(): Promise<ImageData | void>;
}
export declare interface ILiveSrc {
liveStreamId: string;
liveAdaptiveManifest?: Record<string, unknown>[];
multiResolutionPlayUrls?: Record<string, unknown>[];
playUrls?: Record<string, unknown>[];
[key: string]: unknown;
}
/**
* @public
*/
declare interface ILogger {
e: LogOutputFunc;
w: LogOutputFunc;
i: LogOutputFunc;
d: LogOutputFunc;
v: LogOutputFunc;
}
/**
* @public
*/
declare interface ILogger_2 {
e: LogOutputFunc_2;
w: LogOutputFunc_2;
i: LogOutputFunc_2;
d: LogOutputFunc_2;
v: LogOutputFunc_2;
setOutput?(output?: ILogger_2): ILogger_2 | undefined;
}
/**
* 输入媒体描述
* 输入MediaDescription或者MixContainerMediaDescription数组
* 输入MixContainerMediaDescription数组时,播放SDK会以数组顺序作为优先级选择浏览器可支持的视频类型
* @example
* 输入flv流和hls流,在大部分情况都会播放flv格式的流,在iOS上会播放hls的流
* ```
* [
* {src: "http://xxxx/xxx.flv"},
* {src: "http://xxxx/xxx.m3u8"}
* ]
* ```
* @see MediaDescription
* @see MixContainerMediaDescription
* @public
*/
declare type InputMediaDescription = MediaDescription | MixContainerMediaDescription[];
export declare type InputSrc = {
isLive: true;
src: ILiveSrc;
} | {
isLive: false;
src: IVideoSrc[] | Manifest;
} | '';
export declare type InteractionData = {
type: 'progresschange';
data: {
time: number;
};
} | {
type: Exclude<InteractionType, InteractionTypeWithData>;
};
export declare type InteractionType = 'clicknext' | 'clickprev' | 'clicklogin' | 'clickregister' | 'clicksenddanmaku' | 'clickvip' | InteractionTypeWithData;
declare type InteractionTypeWithData = 'progresschange';
/**
* @public
*/
declare interface IPlayerEventEmitter {
on<eventName extends keyof PlayerEventMap>(event: eventName, listener: PlayerEventMap[eventName]): void;
once<eventName extends keyof PlayerEventMap>(event: eventName, listener: PlayerEventMap[eventName]): void;
removeAllListeners<eventName extends keyof PlayerEventMap>(event?: eventName): void;
off<eventName extends keyof PlayerEventMap>(event: eventName, listener?: PlayerEventMap[eventName]): void;
emit<eventName extends keyof PlayerEventMap>(event: eventName, eventObject?: Parameters<PlayerEventMap[eventName]>[0]): boolean;
listenerCount<eventName extends keyof PlayerEventMap>(event: eventName): number;
}
export declare interface IVideoSrc {
url: string;
}
export declare interface IYodaError {
type: string;
originalError: {
message: string;
code?: number;
};
}
export declare type IYodaEventMap = {
play: IBaseContextEvent<'play'>;
playing: IBaseContextEvent<'playing'>;
pause: IBaseContextEvent<'pause'>;
loadedmetadata: IBaseContextEvent<'loadedmetadata', {
duration: number;
}>;
timeupdate: IBaseContextEvent<'timeupdate', {
to: number;
}>;
ended: IBaseContextEvent<'ended'>;
waiting: IBaseContextEvent<'waiting'>;
seeked: IBaseContextEvent<'seek', {
to: number;
}>;
seeking: IBaseContextEvent<'seeking'>;
fullscreenchange: IBaseContextEvent<'fullscreenchange', {
isFull: boolean;
}>;
abloopended: IBaseContextEvent<'abloopended'>;
error: IBaseContextEvent<'error', IYodaError>;
speedChange: IBaseContextEvent<'speedChange', {
speed: number;
}>;
resize: IBaseContextEvent<'resize', {
width: number;
height: number;
}>;
firstFrame: IBaseContextEvent<'firstFrame'>;
};
export declare const IYodaKernel: {
prototype: IYodaKernel;
new (container: HTMLElement, logger: ILogger_2, conf?: Partial<UserConfig>): IYodaKernel;
};
export declare interface IYodaKernel {
readonly duration: number;
readonly videoWidth: number;
readonly videoHeight: number;
readonly seeking: boolean;
readonly paused: boolean;
readonly readyState: number;
readonly ended: boolean;
readonly error?: IYodaError;
readonly actionOnReady?: ActionOnReady;
autoplay: boolean;
loop: boolean;
defaultMuted: boolean;
muted: boolean;
defaultPlaybackRate: number;
playbackRate: number;
src: InputSrc | undefined;
currentTime: number;
objectFit: 'contain' | 'fill' | 'cover';
updateUserConfig(conf?: Partial<UserConfig>): void;
play(): Promise<void>;
pause(): Promise<void>;
destroy(): Promise<void>;
isFullscreen(): boolean;
fullScreen(direction: FullScreenDirection): Promise<void>;
exitFullScreen(): Promise<void>;
screenshot(): Promise<ImageData | void>;
on<K extends keyof IYodaEventMap>(event: K, listener: (e: IYodaEventMap[K]) => void): void;
once<K extends keyof IYodaEventMap>(event: K, listener: (e: IYodaEventMap[K]) => void): void;
off<K extends keyof IYodaEventMap>(event: K, listener: (e: IYodaEventMap[K]) => void): void;
emit<K extends keyof IYodaEventMap>(event: K, eventObject?: IYodaEventMap[K]): boolean;
prependListener<K extends keyof IYodaEventMap>(event: K, listener: (e: IYodaEventMap[K]) => void): void;
prependOnceListener<K extends keyof IYodaEventMap>(event: K, listener: (e: IYodaEventMap[K]) => void): void;
removeAllListeners<K extends keyof IYodaEventMap>(event?: K): void;
}
/**
* @public
*/
export declare type KernelConfig = {} & BaseConfig & TransConfig & RTCConfig;
/**
* @public
*/
declare interface KernelEventMap {
[KEvents.MANIFEST_PARSED]: (data: ManifestEventData) => void;
[KEvents.LEVEL_SWITCHING]: (data: LevelEventData) => void;
[KEvents.LEVEL_SWITCHED]: (data: LevelEventData) => void;
[KEvents.LEVEL_SWITCH_PLAYING]: (data: LevelEventData) => void;
[KEvents.LEVEL_SWITCH_FAILED]: () => void;
[KEvents.AUDIO_TRACK_UPDATED]: (data: LevelTimeInfo | undefined) => void;
[KEvents.AUDIO_TRACK_SWITCHING]: (data: LevelEventData) => void;
[KEvents.AUDIO_TRACK_SWITCHED]: (data: LevelEventData) => void;
[KEvents.AUDIO_TRACK_SWITCH_FAILED]: () => void;
[KEvents.SUBTITLE_TRACK_SWITCHED]: (data: BaseLevelEventData) => void;
[KEvents.LEVEL_UPDATED]: (data: LevelTimeInfo | undefined) => void;
[KEvents.LOAD_END]: (data: BasicEventData) => void;
[KEvents.VIDEO_RENDERER_CHANGE]: (data: VideoRendererChangeEventData) => void;
[KEvents.H265_DETECTED]: (data: H265DetectedEventData) => void;
[KEvents.ERROR]: (data: ErrorEventData) => void;
[KEvents.REPORT]: (data: ReportData) => void;
[KEvents.SCREENSHOT]: (data: ScreenshotEventData) => void;
}
export declare type KernelType = 'kwai-player-kernel' | 'yoda' | 'unknown';
/**
* @public
*/
declare enum KEvents {
/* Excluded from this release type: METADATA */
/* Excluded from this release type: MEDIA_INFO */
/* Excluded from this release type: PARSING_INIT_SEGMENT */
/* Excluded from this release type: PARSING_DATA */
/* Excluded from this release type: PARSED_DATA */
/* Excluded from this release type: SCRIPT_PARSED */
/* Excluded from this release type: KEY_FRAME_INDEXS */
/* Excluded from this release type: VIDEO_FRAME_INFO */
/* Excluded from this release type: DISCONTINUITY */
/**
* 视频播放相关信息会从该事件抛出,需要根据抛出数据的type类型处理数据
*/
REPORT = "report",
/**
* 下载完成
*/
LOAD_END = "loadEnd",
/**
* 错误
*/
ERROR = "error",
/**
* manifest加载完成
*/
MANIFEST_LOADED = "manifestLoaded",
/**
* manifest解析完成,需要在此事件中处理多码率信息
*/
MANIFEST_PARSED = "manifestParsed",
/**
* level开始切换,开始切换流
*/
LEVEL_SWITCHING = "levelSwitching",
/**
* level已切换,切换的流开始下载
*/
LEVEL_SWITCHED = "levelSwitched",
/**
* level已切换,切换的流开始播放
* 用于平滑切换清晰度,平滑切换清晰度的切换过程会有延迟
*/
LEVEL_SWITCH_PLAYING = "levelSwitchPlaying",
/**
* level切换失败
*/
LEVEL_SWITCH_FAILED = "levelSwitchFailed",
/* Excluded from this release type: LEVEL_LOADED */
/**
* level信息已更新(mediaplylist)
*/
LEVEL_UPDATED = "levelUpdated",
/**
* 音频轨开始切换,用于音视频数据分离的视频
*/
AUDIO_TRACK_SWITCHING = "audioTrackSwitching",
/**
* 音频轨切换完成,用于音视频数据分离的视频
*/
AUDIO_TRACK_SWITCHED = "audioTrackSwitched",
/**
* 音频轨信息已更新(mediaplylist),用于音视频数据分离的视频
*/
AUDIO_TRACK_UPDATED = "audioTrackUpdated",
/**
* 音频轨切换失败
*/
AUDIO_TRACK_SWITCH_FAILED = "audioTrackSwitchFailed",
/* Excluded from this release type: HLS_MANIFEST_PARSED */
/* Excluded from this release type: HLS_KEY_LOADED */
/* Excluded from this release type: AUDIO_TRACK_LOADED */
/* Excluded from this release type: SUBTITLE_TRACK_LOADED */
/* Excluded from this release type: SUBTITLE_LOADED */
/**
* 字幕轨切换完成
*/
SUBTITLE_TRACK_SWITCHED = "subtitleTrackSwitched",
/**
* 字幕轨信息已更新(mediaplylist)
*/
SUBTITLE_TRACK_UPDATED = "subtitleTrackUpdated",
/* Excluded from this release type: BUFFER_CLEANING */
/* Excluded from this release type: VIDEO_SEEK */
/* Excluded from this release type: ABR_NEXT */
/* Excluded from this release type: PRIV_NAL */
/* Excluded from this release type: SEI */
/**
* AAC 私有信息
*/
AAC_PRIV = "aacPriv",
/* Excluded from this release type: RAW_DATA */
/* Excluded from this release type: MP4_NOT_FASTSTART */
/* Excluded from this release type: VIDEO_CODEC_DETECTED */
/**
* 检测到h265,需要解码器
* @deprecated VIDEO_RENDERER_CHANGE替代
*/
H265_DETECTED = "h265Detected",
/**
* 渲染方式变更
*/
VIDEO_RENDERER_CHANGE = "videoRendererChange",
/* Excluded from this release type: DEC_LIB_LOADED */
/* Excluded from this release type: DEC_INIT_COMPLETE */
/* Excluded from this release type: DEC_VIDEO_READY */
/* Excluded from this release type: STEP */
/* Excluded from this release type: RENDERER_INIT_COMPLETE */
/* Excluded from this release type: RENDERER_BUF_EXPIRED */
/* Excluded from this release type: RENDERER_SEEK */
/* Excluded from this release type: RENDERER_BUF_UPDATE */
/* Excluded from this release type: RENDERER_DRAW */
/* Excluded from this release type: RENDERER_WAITING */
/* Excluded from this release type: RENDERER_WAITING_END */
/* Excluded from this release type: DECODER_FRAME */
/* Excluded from this release type: DECODER_IMG */
/* Excluded from this release type: DECODER_SEEK */
/* Excluded from this release type: DECODER_SEEK_ABORT */
/* Excluded from this release type: DECODER_WAITING */
/* Excluded from this release type: DECODER_DATA_END */
/* Excluded from this release type: DECODER_BUF_LOW */
/* Excluded from this release type: DECODER_DROP_FRAME */
/* Excluded from this release type: DECODER_MEDIA_INFO */
/* Excluded from this release type: MEDIA_CONNECTED */
/* Excluded from this release type: LOADER_CHUNK_ARRIVAL */
/* Excluded from this release type: DEMUXER_DETECTED */
/* Excluded from this release type: MEDIA_DEMUX */
/* Excluded from this release type: KEY_FRAME */
/* Excluded from this release type: USE_BACKUP */
/* Excluded from this release type: NEW_SOURCE */
/* Excluded from this release type: DOWNLOAD */
/* Excluded from this release type: STOP_LOAD */
/* Excluded from this release type: LOAD */
/* Excluded from this release type: WAITING */
/* Excluded from this release type: LOADEDMETADATA */
/* Excluded from this release type: LOADEDDATA */
/* Excluded from this release type: CANPLAY */
/* Excluded from this release type: SEEKING */
/* Excluded from this release type: SEEK_WITH_LOAD */
/* Excluded from this release type: SEEKED */
/* Excluded from this release type: PLAYING */
/* Excluded from this release type: PAUSE */
/* Excluded from this release type: PLAY */
/* Excluded from this release type: ENDED */
/* Excluded from this release type: TIMEUPDATE */
/* Excluded from this release type: PROGRESS */
/* Excluded from this release type: RATE_CHANGE */
/* Excluded from this release type: DURATION_CHANGE */
/* Excluded from this release type: HEARTBEAT */
/* Excluded from this release type: MSE_UPDATE */
/* Excluded from this release type: MSE_BUFFER_FULL */
/* Excluded from this release type: MSE_SOURCE_CLOSE */
/* Excluded from this release type: RETRY */
/* Excluded from this release type: WORKER_LOG */
/* Excluded from this release type: VISIBILITY_CHANGE */
/**
* 截图
*/
SCREENSHOT = "screenshot"
}
/**
* REPORT事件 type === KEY_FRAME 数据
* @public
*/
declare type KeyFrameReportData = {
cts: number;
pts: number;
};
/**
* @public
*/
declare type KeyLoaderConfig = {
emeEnabled: boolean;
widevineLicenseUrl: string;
playreadyLicenseUrl: string;
fairplayLicenseUrl: string;
keyLoadingMaxRetry: number;
keyConnectionTimeout: number;
keyTransmissionTimeout: number;
keyLoadingRetryDelay: number;
};
/**
* @public
*/
declare type KLevel = {
width?: number;
height?: number;
qualityLabel?: string;
qualityType?: string;
bitrate: number;
maxBitrate?: number;
};
/**
* @public
*/
declare type KwaiAdaptationSet = {
id: number;
duration: number;
drmSchemaId?: string;
drmToken?: string;
mimeType?: string;
language?: string;
representation: KwaiRepresentation[];
} & Record<string, unknown>;
/**
* @public
*/
declare type KwaiManifest = {
version: string;
businessType: number;
mediaType: number;
videoId?: string;
hideAuto?: boolean;
manualDefaultSelect?: boolean;
stereoType?: number;
videoBaseFeature?: string;
videoAestheticFeature?: string;
videoFeature?: {
blurProbability: number;
blockyProbability: number;
avgEntropy: number;
mosScore: number;
};
programStartTime?: number;
adaptationSet: KwaiAdaptationSet[];
} & Record<string, unknown>;
/**
* 创建播放实例
*
* @param id 播放组件所在Dom容器ID
* @param data 播放组件传入的参数
*
* @extends EventEmitter
*
* @example
* // 自动播放
* new KwaiPlayer('container-id',{
* autoplay: true,
* })
* @example
* // 指定内核参数,如优先使用原生播放
* new KwaiPlayer('container-id',{
* config:{
* nativeFirst: true
* }
* })
* @public
*/
export declare class KwaiPlayer implements IKwaiPlayer {
static packVersion: string;
/* Excluded from this release type: _pluginBase */
/* Excluded from this release type: _eventHandlers */
/* Excluded from this release type: _evt */
/* Excluded from this release type: _mainDom */
/* Excluded from this release type: _video */
/* Excluded from this release type: _kernel */
/* Excluded from this release type: _error */
/* Excluded from this release type: _config */
/* Excluded from this release type: _src */
/* Excluded from this release type: _autoplay */
/* Excluded from this release type: _preload */
/* Excluded from this release type: _poster */
/* Excluded from this release type: _controls */
/* Excluded from this release type: _videoWidth */
/* Excluded from this release type: _videoHeight */
/* Excluded from this release type: _kernelLoaded */
/* Excluded from this release type: _livePaused */
/* Excluded from this release type: _canvas */
/* Excluded from this release type: _mediaInfo */
/* Excluded from this release type: _logger */
/* Excluded from this release type: _isLiveShift */
/* Excluded from this release type: _full */
/* Excluded from this release type: _subContainerNumber */
/* Excluded from this release type: _data */
/* Excluded from this release type: _id */
/* Excluded from this release type: _videoLayer */
/* Excluded from this release type: _videoInteractiveLayer */
/* Excluded from this release type: _posterLayer */
/* Excluded from this release type: _preprocessSrcFunc */
/* Excluded from this release type: _preprocessURL */
/* Excluded from this release type: _kernelStartTimeout */
/* Excluded from this release type: _instanceId */
/* Excluded from this release type: _yodaClass */
/* Excluded from this release type: _yodaDom */
/* Excluded from this release type: _yoda */
/* Excluded from this release type: _kernelType */
/* Excluded from this release type: _outputLogger */
/* Excluded from this release type: _yodaEnabled */
/* Excluded from this release type: _screenshotId */
/* Excluded from this release type: _screenshotQueue */
/* Excluded from this release type: _observer */
/* Excluded from this release type: _objectFit */
static get version(): string;
constructor(id: string | HTMLElement, data?: KwaiPlayerData);
/**
* 获取版本号
*/
get version(): string;
/**
* 获取包版本号
*/
get packVersion(): string;
/**
* 实例ID
*/
get instanceId(): number;
/**
* 获取内核类型
*/
get kernelType(): KernelType;
/**
* 本地日志实例
*/
get logger(): ILogger_2;
get outputLogger(): ILogger_2 | undefined;
set outputLogger(val: ILogger_2 | undefined);
/**
* 配置
*/
get config(): Partial<KernelConfig> | undefined;
set config(val: Partial<KernelConfig> | undefined);
/**
* 获取当前错误
*/
get error(): ErrorMsg | undefined;
/**
* videoId
*/
get videoId(): string | undefined;
set videoId(val: string | undefined);
/**
* 设置预览图url
* @remark 依赖预览图插件
*/
get previewUrl(): string | undefined;
set previewUrl(val: string | undefined);
/**
* 设置弹幕防挡url
* @remark 依赖弹幕防挡插件
*/
get maskUrl(): string | undefined;
set maskUrl(val: string | undefined);
/**
* 禁用弹幕防挡url
*/
get disableMask(): boolean | undefined;
set disableMask(val: boolean | undefined);
/**
* 获取播放地址
*/
get src(): MediaDescription | unknown;
set src(val: MediaDescription | unknown);
/**
* 获取当前是否时移回放
*/
get isLiveShift(): boolean;
set liveShiftType(val: LiveShiftType);
/**
* 直播时移类型
*/
get liveShiftType(): LiveShiftType;
set crossOrigin(val: string | null);
/**
* 跨域配置
*/
get crossOrigin(): string | null;
/**
* 网络状态
*/
get networkState(): number;
/**
* 预加载配置
*/
get preload(): PreloadStr;
set preload(val: PreloadStr);
/**
* 获取预加载配置
*/
get buffered(): TimeRanges | undefined;
/**
* 获取video元素readyState
*/
get readyState(): number;
/**
* 获取video元素seeking状态
*/
get seeking(): boolean;
/**
* 获取video播放时间
*/
get currentTime(): number;
set currentTime(val: number);
/**
* 获取video时长
*/
get duration(): number;
/**
* 获取暂停状态
*/
get paused(): boolean;
/**
* 获取默认倍速
*/
get defaultPlaybackRate(): number;
set defaultPlaybackRate(val: number);
/**
* 获取当前倍速
*/
get playbackRate(): number;
set playbackRate(val: number);
/**
* 获取是否播放
* yoda返回undefined
*/
get played(): TimeRanges | undefined;
/**
* 获取是否可以seek
* yoda返回undefined
*/
get seekable(): TimeRanges | undefined;
/**
* 获取是否播放完成
*/
get ended(): boolean;
/**
* 获取是否自动播放
*/
get autoplay(): boolean;
set autoplay(val: boolean);
/**
* 获取是否循环播放
*/
get loop(): boolean;
set loop(val: boolean);
/**
* 获取是否显示控制条
*/
get controls(): boolean | string;
set controls(val: boolean | string);
/**
* 音量
* yoda始终返回1
*/
get volume(): number;
set volume(val: number);
/**
* 获取静音状态
*/
get muted(): boolean;
set muted(val: boolean);
/**
* 获取默认静音状态
*/
get defaultMuted(): boolean;
set defaultMuted(val: boolean);
/**
* 获取视频宽
*/
get videoWidth(): number;
/**
* 获取视频高
*/
get videoHeight(): number;
/**
* 获取封面图
*/
get poster(): string;
set poster(val: string);
/**
* 获取禁用画中画状态
* yoda无效
*/
get disablePictureInPicture(): boolean;
set disablePictureInPicture(val: boolean);
/**
* UI中是否展示下载按钮
*/
get disableDownload(): boolean | undefined;
set disableDownload(val: boolean | undefined);
/**
* 获取是否内联(inline)播放
*/
get playsinline(): boolean;
set playsinline(val: boolean);
/**
* 获取自适应码率开关状态
*/
get disableAdaptive(): boolean | undefined;
set disableAdaptive(val: boolean | undefined);
/**
* 获取当前视频轨id
*/
get currentLevel(): number;
set currentLevel(val: number);
/**
* 获取即将切换的视频轨id
*/
get nextLevel(): number;
set nextLevel(val: number);
/**
* 获取当前播放帧数
*/
get currentVideoFrame(): number;
set currentVideoFrame(val: number);
/**
* 获取当前视频总帧数
*/
get totalVideoFrames(): number;
/**
* 当前清晰度时间信息
*/
get currentLevelTimeInfo(): LevelTimeInfo | undefined;
/**
* 返回当前video
*/
get video(): HTMLVideoElement;
/**
* 返回当前canvas,视频渲染在canvas时有值
*/
get canvas(): HTMLCanvasElement | undefined;
get yodaDom(): HTMLDivElement | undefined;
/**
* 获取当前音频轨id
*/
get audioTrack(): number;
set audioTrack(idx: number);
/**
* 产品ID,用于上报
*/
get productName(): string | undefined;
set productName(val: string | undefined);
/**
* 获取当前是否开启连接预热
* @remarks 依赖预加载插件
*/
get prefetch(): boolean | undefined;
set prefetch(val: boolean | undefined);
/**
* 获取是否显示进度条
* @remarks 依赖控制条插件
*/
get showProgress(): boolean | undefined;
set showProgress(val: boolean | undefined);
/**
* 是否显示时间
* @remarks 依赖控制条插件
*/
get showTime(): boolean | undefined;
set showTime(val: boolean | undefined);
/**
* 获取是否启用热键
* @remarks 依赖热键插件
*/
get disableHotkey(): boolean | undefined;
set disableHotkey(val: boolean | undefined);
/**
* 弹幕是否可用
* @remark 依赖弹幕插件
*/
get disableDanmaku(): boolean | undefined;
set disableDanmaku(val: boolean | undefined);
/**
* 是否渲染弹幕
* @remark 依赖弹幕插件
*/
get danmakuRendering(): boolean | undefined;
set danmakuRendering(val: boolean | undefined);
/**
* 设置是否显示信息面板
* @remarks 依赖信息面板插件
*/
get showInfoPanel(): boolean | undefined;
set showInfoPanel(val: boolean | undefined);
/**
* 是否显示下一个按钮,与UI相关
*/
get showNext(): boolean | undefined;
set showNext(val: boolean | undefined);
/**
* 是否显示上一个按钮,与UI相关
*/
get showPrev(): boolean | undefined;
set showPrev(val: boolean | undefined);
/**
* 业务参数
*/
get bizData(): BizData | undefined;
set bizData(val: BizData | undefined);
/* Excluded from this release type: liveTime */
/* Excluded from this release type: liveTime */
get objectFit(): string;
/**
* 返回当前的内核实例
*/
get kernel(): KwaiPlayerKernel | undefined;
setPreprocessURL(val: PreprocessURL | undefined): void;
setPreprocessSrcFunc(val: PreprocessSrcFunc): void;
/**
* 加载视频
*/
load(): void;
/**
* 播放视频
*/
play(): Promise<void>;
/**
* 暂停视频
*/
pause(): void;
/**
* 开启画中画
*/
requestPictureInPicture(): Promise<PictureInPictureWindow>;
isPictureInPictureAvailable(): boolean;
/**
* 销毁播放器
*/
destroy(): void;
/**
* 重新加载视频
*/
refresh(): void;
/**
* 支持时移时回到直播状态
*/
jumpToLive(): void;
/**
* 获取流时间
* @param val 播放时间,ms
* @returns 播放时间对应的流时间,ms
*/
getStreamTime(val: number): number;
/**
* 注册播放器插件
* @param plugin plugin需继承自PluginModule
*/
static register(plugin: any, method?: RegisterMethod): void;
/**
* 注销播放器插件
* @param plugin 插件或插件名称
*/
static deregister(plugin: any | string): void;
/**
* 设置yoda kernel 定义
* @param val yoda kernel
*/
static setYoda(val: typeof IYodaKernel): void;
/**
* 根据插件名获取插件实例
* @param label 插件名
* @returns plugin
*/
getPluginInstance<pluginLabel extends keyof PluginMap>(label: string | pluginLabel): PluginMap[pluginLabel] | undefined;
/**
* 获取所有的插件实例
* @returns 所有的插件实例
*/
getAllPlugins(): PluginModule[];
/**
* 创建一个子容器
* @returns HTMLDivELement
*/
createSubContainer(layer?: KwaiPlayerLayer): HTMLDivElement;
/**
* 是否全屏
* @returns boolean
*/
isFullscreen(type?: FullscreenType): boolean;
/**
* 开启全屏
* @param type 'system' 系统全屏 'window' 网页全屏
* @returns
*/
requestFullscreen: (type?: FullscreenType) => void;
/**
* 退出全屏
* @param type 'system' 系统全屏 'window' 网页全屏
* @returns
*/
exitFullscreen: (type?: FullscreenType) => void;
isFullscreenAvailable(type?: FullscreenType): boolean;
private _applyObjectFit;
/* Excluded from this release type: _onFullscreenchange */
removeSubContainer(container: HTMLDivElement): void;
/**
* 当前画面截图
* yoda暂不支持截图
* @returns 截图
*/
screenshot(): Promise<ImageData | void>;
private _resolveScreenShotFromQueue;
/**
* 获取主容器
* @returns
*/
get mainContainer(): HTMLElement | null | undefined;
get videoLayer(): HTMLDivElement;
get videoInteractiveLayer(): HTMLDivElement;
/**
* 获取当前QOS信息
* @returns
*/
get audienceStat(): unknown;
/* Excluded from this release type: _updatePosterDom */
/* Excluded from this release type: _hidePosterDom */
/* Excluded from this release type: _setIsUseCanvas */
/* Excluded from this release type: _setError */
/* Excluded from this release type: _resetPlayerStat */
/* Excluded from this release type: _destroyKernel */
/* Excluded from this release type: _destroyYoda */
/* Excluded from this release type: _initYodaKernel */
/* Excluded from this release type: _bindYoda */
/* Excluded from this release type: _bindVideo */
/* Excluded from this release type: _unbindVideo */
/* Excluded from this release type: _parseData */
/* Excluded from this release type: _initKernel */
/* Excluded from this release type: _clearKernelStartTimer */
/* Excluded from this release type: _kernelStart */
/* Excluded from this release type: _onMutedChange */
/* Excluded from this release type: _onVideoLoadstart */
/* Excluded from this release type: _onVideoProgress */
/* Excluded from this release type: _onVideoSuspend */
/* Excluded from this release type: _onVideoAbort */
/* Excluded from this release type: _onVideoEmptied */
/* Excluded from this release type: _onVideoStalled */
/* Excluded from this release type: _onVideoLoadedmetadata */
/* Excluded from this release type: _onVideoLoadeddata */
/* Excluded from this release type: _onVideoCanplay */
/* Excluded from this release type: _onVideoCanplaythrough */
/* Excluded from this release type: _onVideoPlaying */
/* Excluded from this release type: _onVideoWaiting */
/* Excluded from this release type: _onVideoSeeking */
/* Excluded from this release type: _onVideoSeeked */
/* Excluded from this release type: _onVideoEnded */
/* Excluded from this release type: _onVideoDurationchange */
/* Excluded from this release type: _onVideoTimeupdate */
/* Excluded from this release type: _onVideoPlay */
/* Excluded from this release type: _onVideoPause */
/* Excluded from this release type: _onVideoRatechange */
/* Excluded from this release type: _onVideoResize */
/* Excluded from this release type: _onVideoVolumechange */
/* Excluded from this release type: _onVideoEnterpictureinpicture */
/* Excluded from this release type: _onVideoLeavepictureinpicture */
/* Excluded from this release type: _updateIsLiveShift */
/* Excluded from this release type: _isLiveShiftMode */
on<eventName extends keyof PlayerEventMap>(event: eventName, listener: PlayerEventMap[eventName]): void;
once<eventName extends keyof PlayerEventMap>(event: eventName, listener: PlayerEventMap[eventName]): void;
removeAllListeners<eventName extends keyof PlayerEventMap>(event?: eventName | undefined): void;
off<eventName extends keyof PlayerEventMap>(event: eventName, listener: PlayerEventMap[eventName]): void;
listeners<eventName extends keyof PlayerEventMap>(event: eventName): PlayerEventMap[eventName][];
emit<eventName extends keyof PlayerEventMap>(event: eventName, eventObject?: Parameters<PlayerEventMap[eventName]>[0]): boolean;
listenerCount<eventName extends keyof PlayerEventMap>(event: eventName): number;
}
/**
* @public
*/
declare interface KwaiPlayerData {
config?: Partial<KernelConfig>;
src?: MediaDescription | unknown;
crossOrigin?: string | null;
preload?: PreloadStr;
defaultPlaybackRate?: number;
playbackRate?: number;
autoplay?: boolean;
loop?: boolean;
controls?: boolean | string;
volume?: number;
muted?: boolean;
defaultMuted?: boolean;
poster?: string;
disablePictureInPicture?: boolean;
disableDownload?: boolean;
disableAdaptive?: boolean;
disableMask?: boolean;
disableHotkey?: boolean;
disableDanmaku?: boolean;
danmakuRendering?: boolean;
playsinline?: boolean;
videoId?: string;
previewUrl?: string;
maskUrl?: string;
showProgress?: boolean;
showTime?: boolean;
showInfoPanel?: boolean;
showNext?: boolean;
showPrev?: boolean;
prefetch?: boolean;
bizData?: BizData;
liveTime?: LiveTime;
liveShiftType?: LiveShiftType;
productName?: string;
playList?: Array<string | object>;
playIndex?: number;
rotate?: Rotate;
lastPlayTime?: number;
lastPlayTimeHideDelay?: number;
plugins?: PluginOptions;
logger?: ILogger_2;
}
/**
* @public
*/
export declare enum KwaiPlayerEvent {
ERROR = "error",
MANIFEST_PARSED = "manifestparsed",
LEVEL_SWITCHING = "levelswitching",
LEVEL_SWITCHED = "levelswitched",
LEVEL_SWITCH_PLAYING = "levelswitchplaying",
LEVEL_SWITCH_FAILED = "levelswitchfailed",
LEVEL_UPDATED = "levelupdated",
AUDIO_TRACKS_SWITCHING = "audiotrackswitching",
AUDIO_TRACKS_SWITCHED = "audiotrackswitched",
LOADSTART = "loadstart",
PROGRESS = "progress",
SUSPEND = "suspend",
ABORT = "abort",
EMPTIED = "emptied",
STALLED = "stalled",
LOADEDMETADATA = "loadedmetadata",
LOADEDDATA = "loadeddata",
CANPLAY = "canplay",
CANPLAYTHROUGH = "canplaythrough",
PLAYING = "playing",
WAITING = "waiting",
SEEKING = "seeking",
SEEKED = "seeked",
ENDED = "ended",
DURATIONCHANGE = "durationchange",
TIMEUPDATE = "timeupdate",
PLAY = "play",
PAUSE = "pause",
RATECHANGE = "ratechange",
RESIZE = "resize",
VOLUMECHANGE = "volumechange",
ENTER_PICTURE_IN_PICTURE = "enterpictureinpicture",
LEAVE_PICTURE_IN_PICTURE = "leavepictureinpicture",
REPORT = "report",
VIDEO_RENDERER_CHANGE = "videorendererchange",
FULLSCREEN_CHANGE = "fullscreenchange",
ATTRIBUTE_CHANGE = "attribute:change",
/** 交互行为 */
INTERACTION = "interaction",
LIVE_SHIFT_CHANGE = "liveshiftchange",
LIVE_SHIFT_TYPE_CHANGE = "liveshifttypechange",
OBJECT_FIT_CHANGE = "objectfitchange",
ATTRIBUTE_CHANGE_CONFIG = "attribute:change:config",
ATTRIBUTE_CHANGE_SRC = "attribute:change:src",
ATTRIBUTE_CHANGE_VIDEO_ID = "attribute:change:videoid",
ATTRIBUTE_CHANGE_PREVIEW_URL = "attribute:change:previewurl",
ATTRIBUTE_CHANGE_MASK_URL = "attribute:change:maskurl",
ATTRIBUTE_CHANGE_CROSS_ORIGIN = "attribute:change:crossorigin",
ATTRIBUTE_CHANGE_PRELOAD = "attribute:change:preload",
ATTRIBUTE_CHANGE_CURRENT_TIME = "attribute:change:currenttime",
ATTRIBUTE_CHANGE_DEFAULT_PLAYBACK_RATE = "attribute:change:defaultplaybackrate",
ATTRIBUTE_CHANGE_PLAYBACK_RATE = "attribute:change:playbackrate",
ATTRIBUTE_CHANGE_AUTOPLAY = "attribute:change:autoplay",
ATTRIBUTE_CHANGE_LOOP = "attribute:change:loop",
ATTRIBUTE_CHANGE_CONTROLS = "attribute:change:controls",
ATTRIBUTE_CHANGE_VOLUME = "attribute:change:volume",
ATTRIBUTE_CHANGE_MUTED = "attribute:change:muted",
ATTRIBUTE_CHANGE_DEFAULT_MUTED = "attribute:change:defaultmuted",
ATTRIBUTE_CHANGE_POSTER = "attribute:change:poster",
ATTRIBUTE_CHANGE_DISABLE_PICTURE_IN_PICTURE = "attribute:change:disablepictureinpicture",
ATTRIBUTE_CHANGE_PLAYSINLINE = "attribute:change:playsinline",
ATTRIBUTE_CHANGE_DISABLE_ADAPTIVE = "attribute:change:disableadaptive",
ATTRIBUTE_CHANGE_DISABLE_DOWNLOAD = "attribute:change:disabledownload",
ATTRIBUTE_CHANGE_DISABLE_MASK = "attribute:change:disablemask",
ATTRIBUTE_CHANGE_DISABLE_HOTKEY = "attribute:change:disablehotkey",
ATTRIBUTE_CHANGE_DISABLE_DANMAKU = "attribute:change:disabledanmaku",
ATTRIBUTE_CHANGE_DANMAKU_RENDERING = "attribute:change:danmakurendering",
ATTRIBUTE_CHANGE_DANMAKU_CONTROLS_POS = "attribute:change:danmakucontrolspos",
ATTRIBUTE_CHANGE_DANMAKU_CONTROLS_POS_FULLSCREEN = "attribute:change:danmakucontrolsposfullscreen",
ATTRIBUTE_CHANGE_CURRENT_LEVEL = "attribute:change:currentlevel",
ATTRIBUTE_CHANGE_NEXT_LEVEL = "attribute:change:nextlevel",
ATTRIBUTE_CHANGE_CURRENT_FRAME = "attribute:change:currentframe",
ATTRIBUTE_CHANGE_AUDIO_TRACK = "attribute:change:audiotrack",
ATTRIBUTE_CHANGE_PREFETCH = "attribute:change:prefetch",
ATTRIBUTE_CHANGE_SHOW_PROGRESS = "attribute:change:showprogress",
ATTRIBUTE_CHANGE_SHOW_TIME = "attribute:change:showtime",
ATTRIBUTE_CHANGE_SHOW_NEXT = "attribute:change:shownext",
ATTRIBUTE_CHANGE_SHOW_PREV = "attribute:change:showprev",
ATTRIBUTE_CHANGE_BIZ_DATA = "attribute:change:bizdata",
ATTRIBUTE_CHANGE_LIVE_TIME = "attribute:change:livetime",
ATTRIBUTE_CHANGE_SHOW_INFO_PANEL = "attribute:change:showinfopanel",
/** @deprecated */
CLICK_NEXT = "clicknext",
/** @deprecated */
CLICK_LOGIN = "clicklogin",
/** @deprecated */
CLICK_REGISTER = "clickregister",
/** @deprecated */
CLICK_VIP = "clickvip"
}
/**
* KwaiPlayerKernel
* @public
*/
declare class KwaiPlayerKernel extends AbstractDestroyable implements IKEventEmitter {
/* Excluded from this release type: _video */
/* Excluded from this release type: _ctx */
/* Excluded from this release type: _monitor */
/* Excluded from this release type: _error */
/* Excluded from this release type: _exposedEvt */
/* Excluded from this release type: _logger */
/* Excluded from this release type: _destroyed */
/* Excluded from this release type: _iosComp */
/* Excluded from this release type: _evt */
/* Excluded from this release type: _avcore */
static isSupport(config?: {
box?: MediaBox;
isLive?: boolean;
nativeFirst?: boolean;
}): boolean;
/**
* 检测指定视频编码格式的解码能力
* @param videoCodec - 视频编码格式
* @returns 解码能力信息
*/
static videoCodecCapabilities(videoCodec: CodecType): VideoCodecCompatibilityResult;
/**
* 获取版本号
*/
static get version(): string;
/**
* 获取打包时间
*/
static get buildTime(): string;
/**
* @deprecated 已导出类型
*/
static get MediaBox(): typeof MediaBox;
/**
* 获取可能抛出的事件列表
*/
static get Events(): ExposedEvents;
/**
* 获取REPORT事件中可能的类型
*/
static get Reports(): typeof ReportTypes;
/**
* 构造函数
* @param dom - HTMLMediaElement
* @param config - config
*/
constructor(dom: HTMLMediaElement, config?: Partial<KernelConfig>);
on<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
once<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
removeAllListeners<T extends keyof KernelEventMap>(event?: T | undefined): void;
off<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
listeners<T extends keyof KernelEventMap>(event: T): KernelEventMap[T][];
emit<T extends keyof KernelEventMap>(event: T, eventObject?: Parameters<KernelEventMap[T]>[0]): boolean;
listenerCount<T extends keyof KernelEventMap>(event: T): number;
prependListener<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
prependOnceListener<T extends keyof KernelEventMap>(event: T, listener: KernelEventMap[T]): void;
/**
* 开始加载
* @param src - 视频资源,可选
* @param loadConfig - 加载配置,可选
* @returns
*/
load(src?: InputMediaDescription, loadConfig?: LoadConfig): void;
/**
* 当前服务端时间,依赖ntp
* @returns
*/
getTimeNow(): number | null;
/**
* 设置可用的清晰度列表
* @param value - 清晰度id列表
*/
setAvailableAbrLevels(value: number[]): void;
/**
* 添加一个预加载任务,仅HLS长视频
* @param src - src
* @deprecated preload removed 3.3.26
*/
preload(src: BaseMediaDescription, level?: number): void;
/**
* 指定时间是否在video缓冲区内
* @param sec - time
* @returns isTimeinBuffered
*/
isTimeinBuffered(sec: number): boolean;
/**
* 恢复播放。从暂停、停止状态恢复
*/
resume(): void;
/**
* 销毁
*/
destroy(): void;
/**
* 刷新
*/
refresh(): void;
/**
* 停止加载,内核停止,用于直播停止
*/
stopLoad(): void;
/**
* 返回传入时间对应的流时间
* @param time - 时间(毫秒)
* @returns 流时间(毫秒)
*/
getStreamTime(time: number): number;
/**
* 获取当前Qos信息
* @returns
*/
getAudienceStat(): unknown;
/**
* 获取当前媒体信息
* @returns
*/
getMediaInfo(): unknown;
/**
* AB数据
* @param data - AB参数
*/
experiment(data: unknown): void;
/**
* 直播结束通知,调用方法后,流结束或无数据认为是正常结束
* 用于适配各CDN直播结束拉流表现不一致的情况
*/
liveEnd(): void;
/**
* seek至下一帧,totalVideoFrames \> 0时
*/
seekToNextFrame(): void;
/**
* seek至上一帧,totalVideoFrames \> 0时
*/
seekToPrevFrame(): void;
/**
* seek至指定帧数,totalVideoFrames \> 0时
* @param index - 范围[0, totalVideoFrames)
* @deprecated 使用currentVideoFrame替代
* @returns
*/
seekByFrameIndex(index: number): void;
/**
* 截图
*/
screenshot(options?: ScreenshotOptions): void;
/**
* @alpha
* get: 当前直播时移类型,none|kwai|general
*/
get liveShiftType(): LiveShiftType_2;
/**
* @alpha
* get: 当前是否是直播时移状态
*/
get liveShift(): boolean;
/**
* @alpha
* get: 直播时移相对于当前直播时间的延迟,秒
*/
get liveShiftDelaySec(): number;
/**
* get: 当前播放位置对应的帧数
* set: 跳转到指定的帧数,需要totalVideoFrames \> 0
*/
get currentVideoFrame(): number;
set currentVideoFrame(index: number);
/**
* 当前视频总帧数,可能为0
*/
get totalVideoFrames(): number;
/**
* get: 获取当前音频轨id,适用于音视频分离的资源
* set: 设置当前音频轨id,切换音频,适用于音视频分离的资源
*/
get audioTrack(): number;
set audioTrack(value: number);
/**
* get: 获取当前字幕轨id
* set: 设置当前字幕轨id,切换字幕
*/
get subtitleTrack(): number;
set subtitleTrack(value: number);
/**
* get: 获取当前视频轨id
* set: 设置当前视频轨id,立刻切换清晰度
*/
get currentLevel(): number;
set currentLevel(value: number);
/**
* get: 获取即将切换的视频轨id
* set: 平滑切换清晰度,需要流切片/GOP对齐
*/
get nextLevel(): number;
set nextLevel(value: number);
/**
* get: 设置启动清晰度
* @deprecated 在manifest回调时间中处理
*/
get startLevel(): number;
set startLevel(value: number);
/**
* 设置输出的Logger实例,使用console输出的同时从output输出
*/
get outputLog(): ILogger | undefined;
set outputLog(val: ILogger | undefined);
/**
* 自动码率功能是否为开启状态
*/
get autoLevelEnabled(): boolean;
/**
* @alpha
*/
get monitorData(): unknown;
/**
* 当前清晰度时间信息
*/
get currentLevelTimeInfo(): LevelTimeInfo | undefined;
/**
* 实例id
*/
get instanceId(): number;
/* Excluded from this release type: _load */
/* Excluded from this release type: _initAVCore */
/* Excluded from this release type: _onManifestParsed */
/* Excluded from this release type: _onVideoRandererChange */
/* Excluded from this release type: _onLoad */
/* Excluded from this release type: _onRetry */
/* Excluded from this release type: _recoverToNative */
/* Excluded from this release type: _recoverToMse */
/* Excluded from this release type: _recover */
/* Excluded from this release type: _onError */
/* Excluded from this release type: _rendererChanged */
/* Excluded from this release type: _unsupportFrameSeek */
/* Excluded from this release type: _emitError */
/* Excluded from this release type: _bindEvent */
/* Excluded from this release type: _onWindowError */
private _onVisibilityChange;
}
/**
* @public
*/
export declare enum KwaiPlayerLayer {
VIDEO = "video",
VIDEO_INTERACTIVE = "videoInteractive",
DEFAULT = "default"
}
/**
* @public
*/
declare type KwaiRepresentation = {
id: number;
url: string;
backupUrl?: string[];
host?: string;
fileSize: number;
m3u8Slice?: string;
maxBitrate: number;
avgBitrate: number;
codecs?: string;
videoCodec?: string;
width: number;
height: number;
frameRate: number;
quality?: number;
qualityType: string;
qualityLabel: string;
featureP2sp?: boolean;
hidden?: boolean;
disableAdaptive?: boolean;
defaultSelect?: boolean;
comment?: string;
kvqScore?: {
FR: number;
NR: number;
};
hdrType?: number;
drmSchemaId?: string;
drmToken?: string;
} & Record<string, unknown>;
/**
* @public
*/
export declare type LangDict = {
lang: string;
map: LangMap;
}[];
/**
* @public
*/
export declare type LangMap = Record<string, Record<string, string>>;
/**
* @public
*/
export declare type LevelEventData = {
bitrate?: number;
time: number;
smooth: boolean;
auto: boolean;
id: number;
/* Excluded from this release type: fallback */
} & BaseLevelEventData;
/**
* @public
*/
declare type LevelLoaderConfig = {
levelLoadingMaxRetry: number;
levelConnectionTimeout: number;
levelTransmissionTimeout: number;
levelLoadingRetryDelay: number;
levelNoUpdateRetry: number;
} & BaseLoaderConfig;
/**
* @public
*/
declare type LevelMeta = {
comment?: string;
kvqScore?: {
FR: number;
NR: number;
};
} & Record<string, unknown>;
/**
* @public
*/
export declare type LevelTimeInfo = {
live: boolean;
duration: number;
times?: number[];
targetduration?: number;
discontinuity?: {
sn: number;
start: number;
}[];
utcs?: number[];
startSn: number;
endSn: number;
};
/**
* @public
*/
declare type LiveAdaptiveConfig = {
stableBufferDiffThresholdSecond: number;
stableBufferIntervalMs: number;
speedTestTimeoutMs: number;
generateSpeedGapMs: number;
bufferCheckIntervalMs: number;
smoothedSpeedUtilizationRatio: number;
smallSpeedToBitrateRatio: number;
enoughSpeedToBitrateRatio: number;
bufferLowerLimitSecond: number;
recentBufferedSize: number;
smoothedSpeedRatio: number;
isSpeedFullyUsed: boolean;
preferNativeLoader?: boolean;
};
/**
* @public
*/
declare type LiveConfig = {
autoPlaybackRate: boolean;
autoPlaybackRateConf?: AutoPlaybackRateConfig;
ntp?: boolean;
flvLoadEndError?: boolean;
catchUpPausedLive?: boolean;
};
/**
* @public
*/
export declare type LiveShiftParams = {
time: number;
urlParams?: Record<string, string>;
};
/**
* @public
*/
export declare enum LiveShiftType {
NONE = "none",
KWAI = "kwai",
KWAI2 = "kwai2"
}
/**
* @public
*/
declare enum LiveShiftType_2 {
NONE = "none",
KWAI = "kwai",
KWAI2 = "kwai2"
}
/**
* @public
*/
export declare type LiveTime = {
start: number;
end?: number;
};
/**
* @public
*/
declare type LoadConfig = {
startFromSec: number;
};
/**
* @public
*/
declare type LogConfig = {
logLevel?: LogLevel;
logger?: ILogger;
};
/**
* @public
*/
export declare const LoggerPluginLabel = "LoggerPlugin";
/**
* @public
*/
export declare abstract class LoggerPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
beforeInstall(_player: IKwaiPlayer, _options?: LoggerPluginModuleOption): void;
afterInstall(_player: IKwaiPlayer, _options?: LoggerPluginModuleOption): void;
/**
* 增加业务相关数据
* @param key 上报数据key
* @param value 上报数据
*/
addBizLog(_key: string, _value: unknown): void;
appendSummaryField(_key: string, _value: unknown): void;
}
/**
* @public
*/
export declare type LoggerPluginModuleOption = {
reportTypes: string[];
productName: string;
forceSendBeacon?: boolean;
} & PluginOption;
/**
* @public
* 日志等级
*/
declare enum LogLevel {
/** 日志等级-error,只输出error日志 */
NONE = "none",
/** 日志等级-error,只输出error日志 */
ERROR = "e",
/** 日志等级-warn,输出error,warn日志 */
WARN = "w",
/** 日志等级-info,输出error, warn, info日志 */
INFO = "i",
/** 日志等级-debug,输出error, warn, info, debug日志 */
DEBUG = "d",
/** 日志等级-verbose,输出error, warn, info, debug, verbose日志 */
VERBOSE = "v"
}
/**
* @public
*/
declare type LogOutputFunc = (tag: string | object, ...msg: unknown[]) => void;
/**
* @public
*/
declare type LogOutputFunc_2 = (tag: string | object, ...msg: unknown[]) => void;
export declare interface Manifest {
version: string;
videoId: string;
mediaType: 1 | 2;
adaptationSet: Array<{
id: number;
representation: Array<VideoRepresentation>;
[key: string]: unknown;
}>;
[key: string]: unknown;
}
/**
* @public
*/
export declare type ManifestEventData = {
levels: KLevel[];
currentLevel: number;
audioTracks?: AudioTrackInfo[];
audioTrack?: number;
subtitleTracks?: SubtitleTrackInfo[];
subtitleTrack?: number;
stereoType?: StereoType;
auto?: boolean;
isLive?: boolean;
} & BasicEventData;
/**
* @public
*/
declare type ManifestLoaderConfig = {
manifestLoadingMaxRetry: number;
manifestConnectionTimeout: number;
manifestTransmissionTimeout: number;
manifestLoadingRetryDelay: number;
} & BaseLoaderConfig;
/**
* @public
*/
export declare type MaskLayerOptions = {
sameAsVideoRotate?: boolean;
};
/**
* @public
*/
export declare const MaskPluginLabel = "MaskPlugin";
/**
* @public
*/
export declare abstract class MaskPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
abstract addLayer(val: HTMLElement, options?: MaskLayerOptions): void;
abstract removeLayer(val: HTMLElement): void;
readonly abstract active: boolean;
}
/**
* @public
*/
declare enum MediaBox {
flv = "flv",
hls = "hls",
hls_ts = "hls_ts",
hls_fmp4 = "hls_fmp4",
webrtc = "webrtc",
mp4 = "mp4",
raw = "raw",
mp3 = "mp3",
wav = "wav",
aac = "aac",
matroska = "matroska",
ts = "ts",
ivf = "ivf",
yuv = "yuv",
unknown = "unknown"
}
/**
* 媒体描述
* @see BaseMediaDescription
* @see MixCodecMediaDescription
* @public
*/
export declare type MediaDescription = BaseMediaDescription | MixCodecMediaDescription;
/**
* REPORT事件 type === MEDIA_INFO 数据
* @public
*/
export declare type MediaInfoReportData = {
/**
* 单次播放uuid
*/
sid?: string;
/**
* 视频封装类型
*/
box?: MediaBox;
/**
* 是否直播
*/
isLive?: boolean;
/**
* 视频宽
*/
width?: number;
/**
* 视频高
*/
height?: number;
/**
* 视频SAR
*/
sar?: VideoSAR;
/**
* 视频尺寸
*/
codedWidth?: number;
codedHeight?: number;
/**
* 流Host
*/
streamHost?: string;
/**
* 是否有视频轨
*/
hasVideo?: boolean;
/**
* 是否有音频轨
*/
hasAudio?: boolean;
/**
* 音频channel数量
*/
channel?: number;
/**
* 音频采样率
*/
audioSampleRate?: number;
/**
* 画面旋转角度
*/
rotation?: number;
/**
* 帧率
*/
fps?: number;
/**
* 视频profile
*/
profile?: string;
/**
* 视频level
*/
level?: string;
/**
* 视频chromaFormat
*/
chromaFormat?: string;
/**
* 色深
*/
bitDepth?: number;
/**
* 音频码率 单位:kb/s
*/
audioBitrate?: number;
/**
* 视频码率 单位:kb/s
*/
videoBitrate?: number;
/**
* 视频codec str
*/
videoCodec?: string;
/**
* 音频codec str
*/
audioCodec?: string;
/**
* 视频编码类型
*/
videoCodecType?: CodecType;
/**
* 音频编码类型
*/
audioCodecType?: CodecType;
/**
* 颜色信息
*/
colorSpace?: string;
/**
* 颜色信息
*/
colorInfo?: ColorInfo;
/**
* 视频解码器类型
*/
videoDecoder?: Decoder;
/**
* 显卡信息
*/
gpu?: string;
/**
* 硬件加速是否开启
*/
hardwareAccelerated?: boolean;
/**
* 播放核心类型
*/
coreType?: string;
/**
* 包名称
*/
packName?: string;
/**
* 直播时移是否可用
*/
liveShiftEnabled?: boolean;
/**
* 直播时移类型
*/
liveShiftType?: LiveShiftType_2;
/**
* 是否是slice封装
*/
isKwaiSlice?: boolean;
/**
* 是否为enhancedFlv
*/
enhancedFlv?: boolean;
/**
* 当前meta信息
*/
srcMeta?: SrcMeta;
/**
* 当前档位meta信息
*/
currentLevelMeta?: LevelMeta;
/**
* 绑定的tag名
*/
tagName?: string;
};
/**
* @public
*/
declare type Metadata = {
/* Excluded from this release type: keyframes */
/* Excluded from this release type: duration */
/* Excluded from this release type: totalVideoFrames */
videoFramesInfo?: VideoFrameInfo[];
/* Excluded from this release type: mp4MoovSize */
/* Excluded from this release type: mp4FastStart */
/* Excluded from this release type: mp4MoovNoPs */
} & Record<string, unknown>;
/**
* 混合编码媒体描述,输入不同编码的视频源,SDK会根据浏览器解码能力选择一组播放
* @example
* 混合输入HEVC和H264示例
* ```
* {
* hevc: BaseMediaDescription,
* h264: BaseMediaDescription,
* }
* ```
* @public
*/
declare type MixCodecMediaDescription = Partial<Record<CodecType, BaseMediaDescription>> & Record<string, unknown>;
/**
* 参考HTMLSourceElement定义
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement}
* @public
*/
declare type MixContainerMediaDescription = {
src: MediaDescription;
type?: string;
} & Record<string, unknown>;
export declare type ObjectFit = '' | 'fill' | 'cover' | 'contain';
/**
* @public
*/
declare type PeerConnectionConfig = {
peerConnectionTimeout: number;
peerConnectionMaxRetry: number;
peerConnectionRetryDelay: number;
};
export declare interface PlayerEventMap {
[KwaiPlayerEvent.LOADSTART]: () => void;
[KwaiPlayerEvent.PROGRESS]: () => void;
[KwaiPlayerEvent.SUSPEND]: () => void;
[KwaiPlayerEvent.ABORT]: () => void;
[KwaiPlayerEvent.ERROR]: (data: ErrorMsg) => void;
[KwaiPlayerEvent.EMPTIED]: () => void;
[KwaiPlayerEvent.STALLED]: () => void;
[KwaiPlayerEvent.LOADEDMETADATA]: () => void;
[KwaiPlayerEvent.LOADEDDATA]: () => void;
[KwaiPlayerEvent.CANPLAY]: () => void;
[KwaiPlayerEvent.CANPLAYTHROUGH]: () => void;
[KwaiPlayerEvent.PLAYING]: () => void;
[KwaiPlayerEvent.WAITING]: () => void;
[KwaiPlayerEvent.SEEKING]: () => void;
[KwaiPlayerEvent.SEEKED]: () => void;
[KwaiPlayerEvent.ENDED]: () => void;
[KwaiPlayerEvent.DURATIONCHANGE]: () => void;
[KwaiPlayerEvent.TIMEUPDATE]: () => void;
[KwaiPlayerEvent.PLAY]: () => void;
[KwaiPlayerEvent.PAUSE]: () => void;
[KwaiPlayerEvent.RATECHANGE]: () => void;
[KwaiPlayerEvent.RESIZE]: () => void;
[KwaiPlayerEvent.VOLUMECHANGE]: () => void;
[KwaiPlayerEvent.MANIFEST_PARSED]: (data: ManifestEventData) => void;
[KwaiPlayerEvent.LEVEL_SWITCHING]: (data: LevelEventData) => void;
[KwaiPlayerEvent.LEVEL_SWITCHED]: (data: LevelEventData) => void;
[KwaiPlayerEvent.LEVEL_SWITCH_PLAYING]: (data: LevelEventData) => void;
[KwaiPlayerEvent.LEVEL_SWITCH_FAILED]: () => void;
[KwaiPlayerEvent.LEVEL_UPDATED]: (e: LevelTimeInfo) => void;
[KwaiPlayerEvent.AUDIO_TRACKS_SWITCHING]: (data: LevelEventData) => void;
[KwaiPlayerEvent.AUDIO_TRACKS_SWITCHED]: (data: LevelEventData) => void;
[KwaiPlayerEvent.ENTER_PICTURE_IN_PICTURE]: () => void;
[KwaiPlayerEvent.LEAVE_PICTURE_IN_PICTURE]: () => void;
[KwaiPlayerEvent.VIDEO_RENDERER_CHANGE]: (e: VideoRendererChangeEventData) => void;
[KwaiPlayerEvent.FULLSCREEN_CHANGE]: (e: FullscreenEventData) => void;
[KwaiPlayerEvent.REPORT]: (data: ReportData) => void;
[KwaiPlayerEvent.INTERACTION]: (data: InteractionData) => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE]: () => void;
[KwaiPlayerEvent.LIVE_SHIFT_CHANGE]: () => void;
[KwaiPlayerEvent.LIVE_SHIFT_TYPE_CHANGE]: () => void;
[KwaiPlayerEvent.OBJECT_FIT_CHANGE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CONFIG]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SRC]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_VIDEO_ID]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_PREVIEW_URL]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_MASK_URL]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CROSS_ORIGIN]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_PRELOAD]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CURRENT_TIME]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DEFAULT_PLAYBACK_RATE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_PLAYBACK_RATE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_AUTOPLAY]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_LOOP]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CONTROLS]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_VOLUME]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_MUTED]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DEFAULT_MUTED]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_POSTER]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_PICTURE_IN_PICTURE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_PLAYSINLINE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_ADAPTIVE]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_DOWNLOAD]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_MASK]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_HOTKEY]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DISABLE_DANMAKU]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DANMAKU_RENDERING]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DANMAKU_CONTROLS_POS]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_DANMAKU_CONTROLS_POS_FULLSCREEN]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CURRENT_LEVEL]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_NEXT_LEVEL]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_CURRENT_FRAME]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_AUDIO_TRACK]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_PREFETCH]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SHOW_PROGRESS]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SHOW_TIME]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SHOW_NEXT]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SHOW_PREV]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_BIZ_DATA]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_LIVE_TIME]: () => void;
[KwaiPlayerEvent.ATTRIBUTE_CHANGE_SHOW_INFO_PANEL]: () => void;
[KwaiPlayerEvent.CLICK_NEXT]: () => void;
[KwaiPlayerEvent.CLICK_REGISTER]: () => void;
[KwaiPlayerEvent.CLICK_LOGIN]: () => void;
[KwaiPlayerEvent.CLICK_VIP]: () => void;
}
/**
* @public
*/
export declare const PlayInfoPluginLabel = "PlayInfoPlugin";
/**
* @public
*/
export declare abstract class PlayInfoPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
abstract isShow: boolean;
}
/**
* @public
*/
declare type PlayListLoaderConfig = {
headers?: ReqHeader[];
} & ManifestLoaderConfig & LevelLoaderConfig;
/**
* @public
*/
export declare type PluginMap = {
[ControlsPluginLabel]: ControlsPluginModule;
[I18nPluginLabel]: I18nPluginModule;
[LoggerPluginLabel]: LoggerPluginModule;
[HotkeyPluginLabel]: HotkeyPluginModule;
[PlayInfoPluginLabel]: PlayInfoPluginModule;
[RotatePluginLabel]: RotatePluginModule;
[PreviewPluginLabel]: PreviewPluginModule;
[MaskPluginLabel]: MaskPluginModule;
[VRPluginLabel]: VRPluginModule;
[DanmakuPluginLabel]: DanmakuPluginModule;
} & Record<string, PluginModule>;
/**
* 插件定义
* @public
*/
export declare abstract class PluginModule extends EventEmitter {
/**
* 播放插件名
*/
static label: string;
/**
* 版本
*/
static version?: string;
/**
* 当前环境是否支持
*/
static isSupported?: boolean;
static isInstanceOfPlugin(val: any): boolean;
/**
* 控制条插槽按钮
*/
get controlsSoltBtns(): ControlsSoltSvgBtn[] | undefined;
/**
* 播放器实例化前钩子
* @param player 播放器实例
* @param options 实例化播放器时指定的当前插件的参数
*/
beforeInstall(_player: IKwaiPlayer, _options?: PluginOption): void;
/**
* 播放器实例化后钩子
* @param player 播放器实例
* @param options 实例化播放器时指定的当前插件的参数
*/
afterInstall(_player: IKwaiPlayer, _options?: PluginOption): void;
/**
* 播放器销毁前钩子
* @param player 播放器实例
*/
beforeUninstall(_player: IKwaiPlayer): void;
/**
* 播放器销毁后钩子
* @param player 播放器实例
*/
afterUninstall(_player: IKwaiPlayer): void;
abstract getLabel(): string;
}
/**
* @public
*/
export declare type PluginOption = Record<string, unknown>;
/**
* @public
*/
export declare type PluginOptions = Record<string, PluginOption>;
export declare type PreloadStr = '' | 'auto' | 'none' | 'metadata';
/**
* @public
*/
export declare type PreprocessSrcFunc = (val: unknown) => MediaDescription;
/**
* @public
* 仅CZTV使用
*/
declare type PreprocessURL = {
stream?: (val: string) => string;
manifest?: (val: string) => string;
key?: (val: string) => string;
};
/**
* @public
*/
export declare type PreviewImg = {
x: number;
y: number;
w: number;
h: number;
url: string;
start: number;
end: number;
};
/**
* @public
*/
export declare const PreviewPluginLabel = "PreviewPlugin";
/**
* @public
*/
export declare abstract class PreviewPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
abstract getImgByTime(sec: number): PreviewImg | undefined;
readonly abstract hasPreview: boolean;
}
/**
* @public
*/
declare type PrivNalInfo = Record<string, number | string>;
/**
* REPORT事件 type === KEY_FRAME 数据
* @public
*/
declare type PrivNalReportData = {
info: PrivNalInfo[];
} & SampleExtraDataBasic;
export declare type RegisterMethod = 'append' | 'prepend';
/**
* @public
*/
declare type RemuxConfig = {
isLive?: boolean;
gopRemux?: boolean;
streamingMux: boolean;
preferDecoder?: Decoder;
ensureVideo: boolean;
maxAudioFramesDrift: number;
forceKeyFrameOnDiscontinuity: boolean;
wasmDecoderEnabled: boolean;
enableAacPriv?: boolean;
videoEnabled?: boolean;
audioEnabled?: boolean;
mseDecErrSkip: number;
adjustFragTime: boolean;
} & DecrypterConfig & LogConfig;
/**
* @public
*/
declare type RendererConfig = {
mainThreadRendering: boolean;
/**
* @alpha 不推荐设置
*/
preferCanvasType?: CanvasContextType;
/**
* @alpha 对浏览器版本及设备有要求
*/
preferCanvasColorSpace?: PredefinedColorSpace;
};
/**
* @public
*/
export declare type ReportData = {
type: ReportTypes.METADATA;
value: Metadata;
} | {
type: ReportTypes.MEDIA_INFO;
value: MediaInfoReportData;
} | {
type: ReportTypes.HEARTBEAT;
value: HeartbeatReportData;
} | {
type: ReportTypes.DOWNLOAD;
value: DownloadReportData;
} | {
type: ReportTypes.REALTIME_BEACON;
value: Record<string, unknown>;
} | {
type: ReportTypes.DISCONTINUITY;
value: DiscontinuityEventData;
} | {
type: ReportTypes.KEY_FRAME;
value: KeyFrameReportData;
} | {
type: ReportTypes.PRIV_NAL;
value: PrivNalReportData;
} | {
type: ReportTypes.SEI;
value: SEIReportData;
} | {
type: ReportTypes.AAC_PRIV;
value: AACPrivReportData;
};
/**
* @public
*/
declare enum ReportTypes {
/**
* 解析到flv script tag onMetadata时抛出
*/
METADATA = "metadata",
/**
* 解析到音视频信息时抛出
*/
MEDIA_INFO = "mediaInfo",
/**
* 调用load方法后开始计算,每1秒抛出一次
*/
HEARTBEAT = "heartbeat",
/**
* 下载上报
*/
DOWNLOAD = "download",
/**
* 实时上报
*/
REALTIME_BEACON = "realtimeBeacon",
/**
* 流不连续
*/
DISCONTINUITY = "discontinuity",
/**
* 收到关键帧信息
*/
KEY_FRAME = "keyFrame",
/**
* 收到私有nal信息
*/
PRIV_NAL = "privNal",
/**
* 收到SEI
*/
SEI = "sei",
/**
* 收到AAC私有信息
*/
AAC_PRIV = "aacPriv"
}
/**
* @public
*/
declare type ReqHeader = {
header: string;
value: string;
};
declare interface Rotate {
innerRotate: boolean;
clockwise: boolean;
}
/**
* @public
*/
export declare const RotatePluginLabel = "RotatePlugin";
/**
* @public
*/
export declare abstract class RotatePluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
abstract innerRotate: number;
abstract outerRotate: number;
abstract isMirror: boolean;
}
/**
* @public
*/
declare type RTCConfig = {} & SDPLoaderConfig & PeerConnectionConfig;
/**
* @public
*/
declare type SampleExtraDataBasic = {
/** 流时间,ms */
streamTimestamp?: number;
/** 播放时间,ms */
time?: number;
};
/**
* @public
*/
declare type ScreenshotEventData = {
pts: number;
id?: string;
image?: ImageData;
errorCode?: number;
errorMessage?: string;
};
/**
* @public
*/
declare type ScreenshotOptions = {
id?: string;
/**
* @alpha 渲染方式为video时不生效;对浏览器及设备有要求
*/
colorSpace?: PredefinedColorSpace;
};
/**
* @public
*/
declare type SDPLoaderConfig = {
sdpConnectionTimeout: number;
};
/**
* REPORT事件 type === SEI 数据
* @public
*/
declare type SEIReportData = {
sei: BaseSEIPayload[];
} & SampleExtraDataBasic;
declare const _sfc_main: {
name: string;
props: {
id: {
type: StringConstructor;
default: string;
};
config: {
type: ObjectConstructor;
default(): {};
};
plugins: {
type: ObjectConstructor;
default(): {};
};
src: {
type: (StringConstructor | ObjectConstructor)[];
default: string;
};
controls: {
type: (StringConstructor | BooleanConstructor)[];
default: boolean;
};
videoId: {
type: StringConstructor[];
default: string;
};
autoplay: {
type: BooleanConstructor[];
default: boolean;
};
crossOrigin: {
type: (StringConstructor | null)[];
default: null;
};
defaultMuted: {
type: BooleanConstructor[];
default: boolean;
};
defaultPlaybackRate: {
type: NumberConstructor[];
default: number;
};
loop: {
type: BooleanConstructor[];
default: boolean;
};
muted: {
type: BooleanConstructor[];
default: boolean;
};
preload: {
type: (StringConstructor | undefined)[];
default: undefined;
};
poster: {
type: StringConstructor[];
default: string;
};
currentTime: {
type: NumberConstructor[];
};
playbackRate: {
type: NumberConstructor[];
default: number;
};
volume: {
type: NumberConstructor[];
default: number;
};
disablePictureInPicture: {
type: BooleanConstructor[];
default: boolean;
};
playsinline: {
type: BooleanConstructor[];
default: boolean;
};
disableDownload: {
type: BooleanConstructor[];
default: boolean;
};
disableAdaptive: {
type: BooleanConstructor[];
default: boolean;
};
disableHotkey: {
type: BooleanConstructor[];
default: boolean;
};
disableMask: {
type: BooleanConstructor[];
default: boolean;
};
currentLevel: {
type: NumberConstructor[];
default: number;
};
nextLevel: {
type: NumberConstructor[];
default: number;
};
audioTrack: {
type: NumberConstructor[];
default: number;
};
currentVideoFrame: {
type: NumberConstructor[];
default: number;
};
showProgress: {
type: BooleanConstructor[];
default: undefined;
};
showTime: {
type: BooleanConstructor[];
default: undefined;
};
prefetch: {
type: BooleanConstructor[];
default: boolean;
};
showInfoPanel: {
type: BooleanConstructor[];
default: boolean;
};
productName: {
type: StringConstructor[];
default: string;
};
previewUrl: {
type: StringConstructor[];
default: string;
};
maskUrl: {
type: StringConstructor[];
default: string;
};
disableDanmaku: {
type: BooleanConstructor[];
};
danmakuRendering: {
type: BooleanConstructor[];
default: boolean;
};
bizData: {
type: ObjectConstructor[];
};
liveShiftType: {
type: StringConstructor[];
};
};
data(): {
player: undefined;
cid: number;
};
watch: {
config: (val: any) => void;
controls: (val: boolean | string) => void;
videoId: (val: string) => void;
src: (val: any) => void;
autoplay: (val: boolean) => void;
crossOrigin: (val: string) => void;
defaultMuted: (val: boolean) => void;
defaultPlaybackRate: (val: number) => void;
loop: (val: boolean) => void;
muted: (val: boolean) => void;
preload: (val: string | undefined) => void;
poster: (val: string | undefined) => void;
currentTime: (val: number) => void;
playbackRate: (val: number) => void;
volume: (val: number) => void;
disablePictureInPicture: (val: boolean) => void;
playsinline: (val: boolean) => void;
disableDownload: (val: boolean | undefined) => void;
disableAdaptive: (val: boolean | undefined) => void;
disableHotkey: (val: boolean | undefined) => void;
disableMask: (val: boolean | undefined) => void;
currentLevel: (val: number) => void;
nextLevel: (val: number) => void;
audioTrack: (val: number) => void;
currentVideoFrame: (val: number) => void;
showProgress: (val: boolean | undefined) => void;
showTime: (val: boolean | undefined) => void;
prefetch: (val: boolean | undefined) => void;
showInfoPanel: (val: boolean | undefined) => void;
previewUrl: (val: string | undefined) => void;
maskUrl: (val: string | undefined) => void;
disableDanmaku: (val: boolean | undefined) => void;
danmakuRendering: (val: boolean | undefined) => void;
bizData: (val: BizData | undefined) => void;
liveShiftType: (val: LiveShiftType) => void;
};
methods: {
load(): void;
play(): Promise<void> | undefined;
pause(): void;
destroy(): void;
requestPictureInPicture(): Promise<PictureInPictureWindow> | undefined;
isFullscreen(type?: FullscreenType): boolean;
requestFullscreen(type?: FullscreenType): void;
exitFullscreen(type?: FullscreenType): void;
isFullscreenAvailable(type?: FullscreenType): boolean;
screenshot(): Promise<void | ImageData>;
getError(): {
code: number;
message: string;
} | undefined;
getNetworkState(): number;
getBuffered(): TimeRanges | undefined;
getReadyState(): number;
getSeeking(): boolean;
getDuration(): number;
getPaused(): boolean;
getSeekable(): TimeRanges | undefined;
getEnded(): boolean;
getVideoWidth(): number | undefined;
getVideoHeight(): number | undefined;
getTotalVideoFrames(): number;
setSrc(val: any): void;
getSrc(): any;
setConfig(val: any): void;
getConfig(): any;
setCrossOrigin(val: string | null): void;
getCrossOrigin(): string | null;
setPreload(val: string): void;
getPreload(): string;
setCurrentTime(val: number): void;
getCurrentTime(): number;
setDefaultPlaybackRate(val: number): void;
getDefaultPlaybackRate(): number;
setPlaybackRate(val: number): void;
getPlaybackRate(): number;
setAutoplay(val: boolean): void;
getAutoplay(): boolean;
setLoop(val: boolean): void;
getLoop(): boolean;
setControls(val: boolean | string): void;
getControls(): boolean | string;
setVideoId(val: boolean | string): void;
getVideoId(): boolean | string;
setVolume(val: number): void;
getVolume(): number;
setMuted(val: boolean): void;
getMuted(): boolean;
setDefaultMuted(val: boolean): void;
getDefaultMuted(): boolean;
setPoster(val: string): void;
getPoster(): string;
setDisablePictureInPicture(val: boolean): void;
getDisablePictureInPicture(): boolean;
setPlaysinline(val: boolean): void;
getPlaysinline(): boolean;
setDisableDownload(val: boolean | undefined): void;
getDisableDownload(): boolean | undefined;
setDisableAdaptive(val: boolean | undefined): void;
getDisableAdaptive(): boolean | undefined;
setDisableHotkey(val: boolean | undefined): void;
getDisableHotkey(): boolean | undefined;
setDisableMask(val: boolean | undefined): void;
getDisableMask(): boolean | undefined;
setCurrentLevel(val: number): void;
getCurrentLevel(): number;
setNextLevel(val: number): void;
getNextLevel(): number;
setAudioTrack(val: number): void;
getAudioTrack(): number;
setCurrentVideoFrame(val: number): void;
getCurrentVideoFrame(): number;
setShowProgress(val: boolean | undefined): void;
getShowProgress(): boolean | undefined;
setShowTime(val: boolean | undefined): void;
getShowTime(): boolean | undefined;
setPrefetch(val: boolean | undefined): void;
getPrefetch(): boolean | undefined;
setShowInfoPanel(val: boolean | undefined): void;
getShowInfoPanel(): boolean | undefined;
setProductName(val: string | undefined): void;
getProductName(): string | undefined;
setPreviewUrl(val: string | undefined): void;
getPreviewUrl(): string | undefined;
setMaskUrl(val: string | undefined): void;
getMaskUrl(): string | undefined;
setDisableDanmaku(val: boolean | undefined): void;
getDisableDanmaku(): boolean | undefined;
setDanmakuRendering(val: boolean | undefined): void;
getDanmakuRendering(): boolean | undefined;
getAudienceStat(): any;
getStreamTime(val: number): number;
getIsLiveShift(): boolean;
getLiveShiftType(): LiveShiftType;
setLiveShiftType(val: LiveShiftType): void;
getVersion(): string;
getPluginInstance<pluginLabel extends string>(label: string | pluginLabel): PluginMap[pluginLabel] | undefined;
getAllPlugins(): PluginModule[] | undefined;
};
created(): void;
mounted(): void;
beforeUnmount(): void;
};
export { _sfc_main as KwaiPlayerVue2 }
export default _sfc_main;
/**
* @public
*/
declare type SrcMeta = {
version?: string;
videoId?: string;
videoMimeType?: string;
audioMimeType?: string;
subtitleMimeType?: string;
videoBaseFeature?: string;
videoAestheticFeature?: string;
videoFeature?: unknown;
videoDuration?: number;
audioDuration?: number;
programStartTime?: number;
} & Record<string, unknown>;
/**
* 全景视频
* @public
*/
declare enum StereoType {
Normal = 0,
V360 = 1,
V180 = 2
}
/**
* @public
*/
declare type StreamLoaderConfig = {
httpRangeType: HttpRangeType;
maxFragFailSec: number;
autoLazyLoad?: boolean;
lazyLoadMaxDuration: number;
lazyLoadRecoverDuration: number;
maxRetry: number;
connectionTimeout: number;
transmissionTimeout: number;
retryDelay: number;
breakpointContinuation: boolean;
} & BaseLoaderConfig;
/**
* @public
*/
declare type SubtitleTrackInfo = {
lang?: string;
name?: string;
groupId: string;
default?: boolean;
};
/**
* @public
*/
declare type TransConfig = {
webWorker: boolean;
} & StreamLoaderConfig & AbrConfig & RemuxConfig & DecConfig & DecLibLoaderConfig & PlayListLoaderConfig & KeyLoaderConfig;
export declare type UserConfig = {
autoplay?: boolean;
loop?: boolean;
objectFit?: 'contain' | 'fill' | 'cover';
triggerBufferUpdate?: boolean;
muted?: boolean;
enableMixAudio?: boolean;
disableNativeControlMixAudio?: boolean;
defaultMuted?: boolean;
defaultPlaybackRate?: number;
playbackRate?: number;
logger?: ILogger_2;
startTime?: number;
biz?: BizData;
};
/**
* @public
*/
declare type VideoCodecCompatibilityResult = {
decoder: Decoder;
smooth: boolean;
mix: boolean;
};
/**
* @public
*/
declare enum VideoDecBlockPolicy {
NONE = "none",
WAITING = "waiting"
}
/**
* @public
*/
declare enum VideoDropFramePolicy {
AUTO = "auto",
MIN = "min"
}
/**
* @public
*/
declare type VideoFrameInfo = {
index: number;
dts: number;
pts: number;
duration: number;
};
/**
* @public
*/
export declare type VideoRendererChangeEventData = {
enabled: boolean;
canvas?: HTMLCanvasElement;
type: VideoRendererType;
};
/**
* @public
*/
declare enum VideoRendererType {
video = "video",
canvas = "canvas"
}
declare interface VideoRepresentation {
id: number;
width: number;
height: number;
quality: number;
qualityType: string;
qualityLabel: string;
[key: string]: unknown;
}
/**
* @public
*/
declare type VideoSAR = {
width: number;
height: number;
};
/**
* @public
*/
export declare const VRPluginLabel = "VRPlugin";
/**
* @public
*/
export declare abstract class VRPluginModule extends PluginModule {
static label: string;
/**
* @override
*/
getLabel(): string;
abstract active: boolean;
abstract sensorActive: boolean;
abstract xAxis: number;
abstract yAxis: number;
}
/**
* @public
* 水印插件的水印适配规则
* 仅在video区域或铺满播放器区域
*/
export declare enum WatermarkFit {
VIDEO = "video",
FILL = "fill"
}
export { }