flvjs api 中文[通俗易懂]

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

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

主要方法: flvjs.createPlayer()

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

Jetbrains全家桶1年46,售后保障稳定

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

MediaDataSource

Field

Type

Description

中文

type

string

Indicates media type, 'flv' or 'mp4'

类型

isLive?

boolean

Indicates whether the data source is a live stream

是否直播

cors?

boolean

Indicates whether to enable CORS for http fetching

跨域

withCredentials?

boolean

Indicates whether to do http fetching with cookies

是否携带COOKIES

hasAudio?

boolean

Indicates whether the stream has audio track

开启声音

hasVideo?

boolean

Indicates whether the stream has video track

开启图像

duration?

number

Indicates total media duration, in milliseconds

媒体时间总长度,毫秒

filesize?

number

Indicates total file size of media file, in bytes

文件大小

url?

string

Indicates 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

Field

Type

Description

中文

duration

number

Required field, indicates segment duration in milliseconds

媒体时间总长度,毫秒

filesize?

number

Optional field, indicates segment file size in bytes

文件大小

url

string

Required field, indicates segment file URL

媒体网络地址

Config

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.

精确寻帧到任何帧,不局限于视频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?

boolean

false

Send Range: bytes=0- for first time load if use Range seek

发送范围:Range: bytes=0- 如果使用范围查找第一次加载

customSeekHandler?

object

undefined

Indicates a custom seek handler

指示自定义查找处理程序

reuseRedirectedURL?

boolean

false

Reuse 301/302 redirected url for subsequence request like seek, reconnect, etc.

重用301/302重定向url,用于随后的请求,如查找、重新连接等。

referrerPolicy?

string

no-referrer-when-downgrade

Indicates the Referrer Policy when using FetchStreamLoader

指示使用FetchStreamLoader时的引用方策略

headers?

object

undefined

Indicates 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;

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

自己看的,请大家指错。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/200696.html原文链接:https://javaforall.cn

相关文章

学习编程是顺着互联网的发展潮流,是一件好事。新手如何学习...
IT行业是什么工作做什么?IT行业的工作有:产品策划类、页面...
女生学Java好就业吗?女生适合学Java编程吗?目前有不少女生...
Can’t connect to local MySQL server through socket \'/v...
oracle基本命令 一、登录操作 1.管理员登录 # 管理员登录 ...
一、背景 因为项目中需要通北京网络,所以需要连vpn,但是服...