flvjs api 中文[通俗易懂]

flvjs api 中文[通俗易懂]flvjs.createPlayer()functioncreatePlayer(mediaDataSource:MediaDataSource,config?:Config):Player;MediaDataSource Field Type Description type string Indicatesmediatype,’flv’or’mp4′ isLive? boolean Indic…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

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

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

原文: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 > 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? 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.net/200696.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 小强面试记

    小强面试记

    2021年5月25日
    146
  • Java进阶学习路线图「建议收藏」

    Java进阶学习路线图「建议收藏」第一阶段技术名称技术内容J2SE(Java基础部分)java开发前奏计算机基本原理,Java语言发展简史以及开发环境的搭建,体验Java程序的开发,环境变量的设置,程序的执行过程,相关反编译工具介绍,java开发工具Eclipse的安装和使用,javadoc的说明。Java基

    2022年5月16日
    39
  • Java反射机制及其使用

    Java反射机制及其使用文章目录1Java反射机制概述2反射及其使用2.1关于类java.lang.Class2.2类的加载2.2.1类的加载过程2.2.2类加载器2.3反射的使用2.3.1创建运行时类的对象2.3.2获取运行时类的属性结构2.3.3获取运行时类的方法结构2.3.4获取运行时类的构造器结构2.3.5获取运行时类的父类信息2.3.6获取运行时类实现的接口2.3.7获取运行时类声明的注解2.3.7获取运行时类所在的包2.3.8调用类的构造函数、操作类的属性、调用类中方法1Java

    2022年7月8日
    17
  • PyCharm 必备插件合集(更新中)

    PyCharm 必备插件合集(更新中)PyCharm的插件很好用,能够在写代码时加成很多。下面看一下目前我用的一些插件。1..ignore我们做的每个Git项目中都需要一个“.gitignore”文件,这个文件的作用就是告诉Git哪些文件不需要添加到版本管理中。插件使用:https://www.jianshu.com/p/bf1bfa0890e82.BashSupportbash-support是一个高度定制化的vim插件,它允许你插入:文件头、补全语句、注释、函数、以及代码块。它也使你可以进行语法检查、使.

    2022年6月24日
    183
  • 23岁的一无所有,其实是理所应当的「建议收藏」

    23岁的一无所有,其实是理所应当的「建议收藏」23岁那年你正处在哪个状态?现在呢? 我,23岁,应届毕业生。生活,工作,爱情都处于人生的低谷,一穷二白,一无所有,一事无成。分享一下成长的建议吧。匿名用户23岁那年…就是去年…… 在22岁的时候我毕业,同时第二年准备考研,结果因为压力太大,期望太高,又失利了,但是我依然满怀信心和憧憬 在我23岁那年四月,当我深爱的女孩(在这之前我追了她四年)说她要去北京时,我在毫无准备的情况下,…

    2022年7月25日
    10

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号