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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • nand flash用途_flash基础测试试题

    nand flash用途_flash基础测试试题NANDFlash的驱动程序设计http://hong60104.spaces.eepw.com.cn/articles/article/item/892051.   硬件特性:【Flash的硬件实现机制】   Flash全名叫做FlashMemory,属于非易失性存储设备(Non-volatileMemoryDevice),非易失性就是不容易丢失,数据存储在这类设备

    2022年10月21日
    6
  • [欧拉回路] hdu 3018 Ant Trip

    [欧拉回路] hdu 3018 Ant Trip

    2021年12月16日
    46
  • pycharm导包时出现错误怎么解决_pycharm引入模块报错

    pycharm导包时出现错误怎么解决_pycharm引入模块报错pycharm导包错误没有警告

    2025年6月15日
    5
  • TCP端口大全_tcpserver和tcpclient介绍

    TCP端口大全_tcpserver和tcpclient介绍1、登录linux部署服务器,用命令查找配置文件elasticsearch.yml,如图find-nameelasticsearch.yml2、进到elasticsearch.yml文件的目录3、查看tcp,http端口

    2025年12月16日
    3
  • php autoconf 配置,automake,autoconf使用详解

    php autoconf 配置,automake,autoconf使用详解作为Linux下的程序开发人员,大家一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile,如果要想写出一个符合自由软件惯例的Makefile就不那么容易了.在本文中,将给大家介绍如何使用autoconf和automake两个工具来帮助我们自动地生成符合自由软件惯例的Makefile,这样就可以象常见的GNU程序一样,只要…

    2022年5月4日
    87
  • JQuery安装与下载教程(efficiency)

    JQuery安装与下载教程(efficiency)一.认识(1)jQuery文件有两个常用版本:一个是1.x版本,另一个是3.x版本。3.x版本是目前的最新版本,与1.x版本有着相同的API。1.x版本兼容IE6、IE7和IE8,而3.x版本不兼容IE6、IE7和IE8。在实际开发中,我们建议使用1.x版本,而不是3.x版本,原因有两个:1.现在很多网站还是要考虑兼容IE6~IE8;2.大多数jQuery插件不支持3.x版本,只支持1.x版本。不管是1.x版本,还是3.x版本

    2022年6月5日
    30

发表回复

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

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