播放器
属性 | 说明 | 类型 | 默认值 |
---|---|---|---|
type | 流媒体类型 | mse: MPEG2-TS/FLV over WebSocket mpegts: MPEG2-TS over HTTP m2ts: flv: HTTPHTTP FLV mp4 |
flv |
isLive | 是否为直播流 | boolean | true |
cors | 是否启用 CORS | boolean | true |
withCredentials | 是否使用cookie | boolean | false |
hasAudio | 是否有音轨 | boolean | false |
hasVideo | 是否有视频轨道 | boolean | true |
duration | 总媒体持续时间,以毫秒为单位 | number | |
filesize | 媒体文件的总文件大小,以字节为单位 | number | |
url | 媒体 URL,可以以'http(s)' 或者 'ws(s)' (WebSocket)开头 |
string | |
segments | Array |
https://github.com/xqq/mpegts.js/blob/master/docs/api.md#config
type MultiPlayerRobustness = {
bufferTime: DOMTimeStamp; // 播放过程中缓冲器最小矫正的时间 默认为1000ms
loopBufferTime: DOMTimeStamp; // 多场时间探测一次 默认5000ms
maxResetTimes: number; // 最大断线重连次数 默认为 5 次
};
https://github.com/xqq/mpegts.js/blob/master/docs/api.md#mpegtsevents
import {MultiPlayerEvent} from "@gaopeng123/multi-player"
const player = document.querySelector('#player');
player.addEventListener(MultiPlayerEvent.STATISTICS_INFO, ({detail}) => {
console.log(detail);
});
https://github.com/xqq/mpegts.js/blob/master/docs/api.md#mpegtserrortypes
import {MultiPlayerError} from "@gaopeng123/multi-player"
const player = document.querySelector('#player');
player.addEventListener(MultiPlayerError.NETWORK_ERROR, ({detail}) => {
console.log(detail);
});
<multi-player
id="player"
media-data-source='{"url": "https://xxx/flv/xxx"}'>
</multi-player>
const player = document.querySelector('#player');
player.addEventListener(MultiPlayerError.NETWORK_ERROR, ({detail}) => {
console.log(detail);
});