EzuikitFlv

EzuikitFlv

EzuikitFlv.js 播放flv直播流, 支持播放h264/h265的直播视频流

Constructor

new EzuikitFlv(options)

Example
import "ezuikit-flv/style.css"
import EzuikitFlv from 'ezuikit-flv'

const flv = new EzuikitFlv({
 id: "EleId",
 url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv"
})
Parameters:
Name Type Description
options FlvOptions

Members

ERROR

Description:
  • EzuikitFlv error events

EzuikitFlv error events

Example
EzuikitFlv.ERROR.playError

ROTATE

Description:
  • 旋转角度

旋转角度

TIMEOUT

_currentPlayDate :string

Type:
  • string

currentTime

Description:
  • 当前播放时间(从0 开始 单位秒)

当前播放时间(从0 开始 单位秒)

playbackRate

Description:
  • 获取倍速

Since:
  • 1.0.3

获取倍速

playbackRate

Description:
  • 设置倍速,仅对萤石设备回放生效

Since:
  • 1.0.3

设置倍速,仅对萤石设备回放生效

services :Services

Type:
  • Services

version

Description:
  • 版本号 EzuikitFlv.version

版本号 EzuikitFlv.version

Example
EzuikitFlv.version

videoInfo

Description:
  • 当前视频的信息, 推荐使用监听 videoInfo 事件

当前视频的信息, 推荐使用监听 videoInfo 事件

Methods

audioResume() → {void}

Description:
  • 音频恢复

Example
player.audioResume()
Returns:
Type
void

closeSound() → {void}

Description:
  • 关闭声音(非静音)

Deprecated:
  • 推荐 player.volume = 0, 后面版本会移除
Example
player.closeSound()
Returns:
Type
void

destroy()

Description:
  • 销毁

Example
player.destroy()

getOptions() → {object}

Description:
  • 获取设置

Example
player.getOptions()
Returns:
Type
object

getState() → {PlayerState}

Description:
  • 获取播放器的状态

Example
player.getState()
Returns:

播放器的状态

Type
PlayerState

getVersion() → {string}

Description:
  • 获取版本

Example
player.getVersion()
Returns:
Type
string

getVolume() → {number}

Description:
  • 获取音量, 音量 0~1

Deprecated:
  • 后面版本会移除, 推荐 player.volume
Example
player.getVolume()
Returns:
Type
number

openSound() → {void}

Description:
  • 开启声音 默认音量 0.8,

Deprecated:
  • 推荐 player.volume = 0.8, 后面版本会移除
Example
player.openSound() //
Returns:
Type
void

pause() → {Promise.<unknown>}

Description:
  • 暂停

Example
flv.pause()
Returns:
Type
Promise.<unknown>

(async) play(optionsopt) → {Promise}

Description:
  • 播放

Example
flv.play()
Parameters:
Name Type Attributes Description
options string | FlvOptions 可选
Returns:
Type
Promise

screenshot(filenameopt, formatopt, qualityopt, type) → {string|Blob|undefined}

Description:
  • 截图,调用后弹出下载框保存截图, (硬解下 Mac Safari 部分截图结果是黑色的)

Since:
  • 1.0.3
Example
player.screenshot()
player.screenshot("filename", "jpeg", 0.7, "download")
Parameters:
Name Type Attributes Default Description
filename string 可选

保存的文件名, 默认 时间戳

format string 可选
png

截图的格式,可选png或jpeg或者webp ,默认 png

quality number 可选
0.92

当格式是jpeg或者webp时,压缩质量,取值0 ~ 1 ,默认 0.92

type "download" | "base64" | "blob" download

download,base64,blob, 默认download

Returns:

undefined 代表截图失败

Type
string | Blob | undefined

setDebug(value) → {void}

Description:
  • 是否开启控制台调试打印

Deprecated:
  • 推荐 player.setLogger({level: "WARN"}), 后面版本会移除
Example
player.setDebug(false)
Parameters:
Name Type Description
value boolean

true: 开启, false: 关闭

Returns:
Type
void

setDefinitionList(list) → {void}

Description:
  • 自定义设置清晰度列表, 仅对萤石设备预览生效, 需要第一次 definitionListChange 事件监听后调用, 不然会被接口覆盖

Since:
  • 1.0.3
Parameters:
Name Type Description
list VideoLevel
Returns:
Type
void

setKeepScreenOn() → {void}

Description:
  • 开启屏幕常亮,在手机浏览器上

Example
flv.setKeepScreenOn()
Returns:
Type
void

setLogger(options) → {void}

Description:
  • 设置日志

Parameters:
Name Type Description
options object

日志设置 {level: 'INFO' | 'LOG' | 'WARN' | 'ERROR'}

Returns:
Type
void

setPlaybackRateList(list) → {void}

Description:
  • 自定义设置倍速列表, 仅对萤石设备回放生效

Since:
  • 1.0.3
Parameters:
Name Type Description
list Array.<number>

倍速列表

Returns:
Type
void

setRotate(deg) → {Promise}

Description:
  • 设置旋转角度,支持,0(默认), 90, 180, 270 四个值。

Deprecated:
  • 不在使用
Example
flv.setRotate(90) // 旋转90度
Parameters:
Name Type Description
deg number

旋转角度取值 EzuikitFlv.ROTATE

Returns:
Type
Promise

setVolume(value) → {void}

Description:
  • 设置音量

Deprecated:
  • 后面版本会移除, 推荐 player.volume = 0.8,
Example
player.setVolume(0.8)
Parameters:
Name Type Description
value number

音量 0~1

Returns:
Type
void

switchDefinition(definition) → {Promise.<number>}

Description:
  • 切换清晰度,仅对萤石设备预览生效

Since:
  • 1.0.3
Parameters:
Name Type Description
definition VideoLevel

清晰

Returns:

0 成功(不代表取流成功), 1 失败

Type
Promise.<number>

switchPlaybackRate(rate) → {Promise.<number>}

Description:
  • 切换倍速,仅对萤石设备回放生效

Since:
  • 1.0.3
Parameters:
Name Type Description
rate number
Returns:

0 成功(不代表取流成功), 1 失败

Type
Promise.<number>

(static) supportType(options) → {boolean}

Description:
  • 静态方法 判断是否支持播放地址

Example
EzuikitFlv.supportType({url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv",  type:'flv'})
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
url string 可选
type string 可选
Returns:
Type
boolean