这种播放内核用于播放flv格式的视频,包括flv点播视频和http-flv直播。(实际上,flv播放内核基于开源组件flv.js开发,在此基础上进行了优化和扩展)
注意
flv直播在html5中仅支持http-flv直播,RTMP的flv直播不支持。
# 使用
在thumbplayer-core中,我们可以按如下方式播放flv视频:
import { KernelFactory } from '@tencent/thumbplayer-core';
// 引入flv播放内核,播放内核会自注册到thumbplayer-core中
import '@tencent/thumbplayer-kernel-flvjs';
const player = KernelFactory.create({
container: '.container',
});
player.play({
url: 'https://thumbplayer-76307.gzc.vod.tencent-cloud.com/testvideo/f00364tdl4t_sd_h264_25fps_480x270.flv',
});
# 配置项(非必须)
const player = KernelFactory.create({
container: '.container',
// 增加flv播放内核配置
flvjsKernelConfig: {
statisticsInfoReportInterval: 600
},
});
flv播放内核常见配置项如下:
Field | Type | Default | Description |
---|---|---|---|
enableWorker? | boolean | false | Enable separated thread for transmuxing (unstable for now) |
enableStashBuffer? | boolean | true | Enable IO stash buffer. Set to false if you need realtime (minimal latency) for live stream playback, but may stalled if there's network jittering. |
stashInitialSize? | number | 384KB | Indicates IO stash buffer initial size. Default is 384KB . Indicate a suitable size can improve video load/seek time. |
isLive? | boolean | false | Same to isLive in MediaDataSource, ignored if has been set in MediaDataSource structure. |
lazyLoad? | boolean | true | Abort the http connection if there's enough data for playback. |
lazyLoadMaxDuration? | number | 3 * 60 | Indicates how many seconds of data to be kept for lazyLoad . |
lazyLoadRecoverDuration? | number | 30 | Indicates the lazyLoad recover time boundary in seconds. |
deferLoadAfterSourceOpen? | boolean | true | Do load after MediaSource sourceopen event triggered. On Chrome, tabs which be opened in background may not trigger sourceopen event until switched to that tab. |
autoCleanupSourceBuffer | boolean | false | Do auto cleanup for SourceBuffer |
autoCleanupMaxBackwardDuration | number | 3 * 60 | When backward buffer duration exceeded this value (in seconds), do auto cleanup for SourceBuffer |
autoCleanupMinBackwardDuration | number | 2 * 60 | Indicates the duration in seconds to reserve for backward buffer when doing auto cleanup. |
fixAudioTimestampGap | boolean | true | Fill silent audio frames to avoid a/v unsync when detect large audio timestamp gap. |
accurateSeek? | boolean | false | Accurate seek to any frame, not limited to video IDR frame, but may a bit slower. Available on Chrome > 50 , FireFox and Safari . |
seekType? | string | 'range' | 'range' use range request to seek, or 'param' add params into url to indicate request range. |
seekParamStart? | string | 'bstart' | Indicates seek start parameter name for seekType = 'param' |
seekParamEnd? | string | 'bend' | Indicates seek end parameter name for seekType = 'param' |
rangeLoadZeroStart? | boolean | false | Send Range: bytes=0- for first time load if use Range seek |
customSeekHandler? | object | undefined | Indicates a custom seek handler |
reuseRedirectedURL? | boolean | false | Reuse 301/302 redirected url for subsequence request like seek, reconnect, etc. |
referrerPolicy? | string | no-referrer-when-downgrade | Indicates the [Referrer Policy][] when using FetchStreamLoader |
headers? | object | undefined | Indicates additional headers that will be added to request |
# 专有事件
player.on(flvjs.Events.MEDIA_INFO, (data: any) => {
console.log(data);
}
更多事件参考flvjs.Events (opens new window)
# 错误码
此播放内核播放时产生的错误码参考