flvjs api 中文

翻译自用,欢迎纠错、补充

原文:https://github.com/bilibili/flv.js/blob/master/docs/api.md

 

主要方法: flvjs.createPlayer()

function createPlayer(mediaDataSource: MediaDataSource, config?: Config): Player;

* 带?号符号的是非必选项

MediaDataSource

Field

TypeDescription中文
typestringIndicates media type, 'flv' or 'mp4'类型
isLive?booleanIndicates whether the data source is a live stream是否直播
cors?booleanIndicates whether to enable CORS for http fetching跨域
withCredentials?booleanIndicates whether to do http fetching with cookies是否携带COOKIES
hasAudio?booleanIndicates whether the stream has audio track开启声音
hasVideo?booleanIndicates whether the stream has video track开启图像
duration?numberIndicates total media duration, in milliseconds媒体时间总长度,毫秒
filesize?numberIndicates total file size of media file, in bytes文件大小
url?stringIndicates media URL, can be starts with 'https(s)' or 'ws(s)' (WebSocket)媒体网络地址
segments?Array<MediaSegment>Optional field for multipart playback, see MediaSegment媒体列表

如果segments参数存在, 则将播放器列为多源媒体播放。

如果是多源媒体播放,则durationfilesizeurl 这三个参数将被忽略。

MediaSegment

FieldTypeDescription中文
durationnumberRequired field, indicates segment duration in milliseconds媒体时间总长度,毫秒
filesize?numberOptional field, indicates segment file size in bytes文件大小
urlstring

Required field, indicates segment file URL

媒体网络地址

Config

FieldTypeDefaultDescription中文
enableWorker?booleanfalseEnable separated thread for transmuxing (unstable for now)多线程工作?
enableStashBuffer?booleantrueEnable 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?number384KBIndicates IO stash buffer initial size. Default is 384KB. Indicate a suitable size can improve video load/seek time.缓存大小
isLive?booleanfalseSame to isLive in MediaDataSource, ignored if has been set in MediaDataSource structure.是否直播,会覆盖上面的配置
lazyLoad?booleantrueAbort the http connection if there's enough data for playback.懒加载,如果缓存到足够的秒数,则停止下载
lazyLoadMaxDuration?number3 * 60Indicates how many seconds of data to be kept for lazyLoad.懒加载最多的秒数
lazyLoadRecoverDuration?number30Indicates the lazyLoad recover time boundary in seconds.缓存剩余秒数时继续下载
deferLoadAfterSourceOpen?booleantrueDo load after MediaSource sourceopen event triggered. On Chrome, tabs which be opened in background may not trigger sourceopen event until switched to that tab. 
autoCleanupSourceBufferbooleanfalseDo auto cleanup for SourceBuffer自动清理缓存
autoCleanupMaxBackwardDurationnumber3 * 60When backward buffer duration exceeded this value (in seconds), do auto cleanup for SourceBuffer 
autoCleanupMinBackwardDurationnumber2 * 60Indicates the duration in seconds to reserve for backward buffer when doing auto cleanup. 
fixAudioTimestampGapbooleantrueFill silent audio frames to avoid a/v unsync when detect large audio timestamp gap.填补无音频帧
accurateSeek?booleanfalseAccurate seek to any frame, not limited to video IDR frame, but may a bit slower. Available on Chrome > 50FireFox and Safari.精确寻帧到任何帧,不局限于视频IDR帧,但可能会慢一点。可在Chrome >火狐和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?booleanfalseSend Range: bytes=0- for first time load if use Range seek发送范围:Range: bytes=0- 如果使用范围查找第一次加载
customSeekHandler?objectundefinedIndicates a custom seek handler指示自定义查找处理程序
reuseRedirectedURL?booleanfalseReuse 301/302 redirected url for subsequence request like seek, reconnect, etc.重用301/302重定向url,用于随后的请求,如查找、重新连接等。
referrerPolicy?stringno-referrer-when-downgradeIndicates the Referrer Policy when using FetchStreamLoader指示使用FetchStreamLoader时的引用方策略
headers?objectundefinedIndicates additional headers that will be added to request添加请求头

method:

    constructor(mediaDataSource: MediaDataSource, config?: Config): Player;
    destroy(): void;
    on(event: string, listener: Function): void;
    off(event: string, listener: Function): void;
    attachMediaElement(mediaElement: HTMLMediaElement): void;
    detachMediaElement(): void;
    load(): void;
    unload(): void;
    play(): Promise<void>;
    pause(): void;
    type: string;
    buffered: TimeRanges;
    duration: number;
    volume: number;
    muted: boolean;
    currentTime: number;
    mediaInfo: Object;
    statisticsInfo: Object;

官方找不到方法的说明。。

 

自己看的,请大家指错。

评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值