Appearance
播放事件监听
1. 自定义播放器事件监听者
ESBasePlayerManagerEventListener
提供播放器事件回调接口。
开发者只需要,继承ESBasePlayerManagerEventListener
,并覆写需要监听的事件。
ESBasePlayerManagerEventListener
类如下:
点击查看源码
vue
export default class ESBasePlayerManagerEventListener {
getId() {
return '';
}
_enabled = true;
setEnabled(enabled) {
this._enabled = enabled;
}
isEnabled() {
return this._enabled;
}
onVideoPlayerInitialized(playerType) {
}
onVideoPlayerPlayInfo(playInfo) {
}
onVideoPlayerPlaySeries(series) {
}
onVideoPlayerPlayUrls(urlList) {
}
onVideoPlayerPlayUrl(url) {
}
onVideoPlayerPreparing() {
}
onVideoPlayerPrepared() {
}
onVideoPlayerBufferStart() {
}
onVideoPlayerBufferEnd() {
}
onVideoPlayerPlaying() {
}
onVideoPlayerProgressChanged(progress) {
}
onVideoPlayerDurationChanged(duration) {
}
onVideoPlayerSeekStart() {
}
onVideoPlayerSeekCompleted() {
}
onVideoPlayerPaused() {
}
onVideoPlayerResumed() {
}
onVideoPlayerSizeChanged() {
}
onVideoPlayerDefinitionListChanged(definitionList) {
}
onVideoPlayerDefinitionChanged(definition) {
}
onVideoPlayerPlayRateListChanged(rateList) {
}
onVideoPlayerPlayRateChanged(rate) {
}
onVideoPlayerDecodeListChanged(decodeList) {
}
onVideoPlayerDecodeChanged(decode) {
}
onVideoPlayerAspectRatioListChanged(aspectRatioList) {
}
onVideoPlayerAspectRatioChanged(aspectRatio) {
}
onVideoPlayerStopped() {
}
onVideoPlayerCompleted() {
}
onVideoPlayerError(errorCode, errorMessage) {
}
onVideoPlayerInfo(type, code, message) {
}
onVideoPlayerNoUrlCanPlay(next) {
}
onVideoPlayerWindowTypeChanged(playerWindowType) {
}
}
自定义播放器事件监听者
注意:getId()方法必须覆写,并且返回唯一的字符串。示例代码:
点击查看源码
vue
import {ESBasePlayerManagerEventListener} from "@extscreen/es-player-manager";
class PlayerEventListener extends ESBasePlayerManagerEventListener {
getId() {
return 'PlayerEventListener';
}
onVideoPlayerPlayInfo(playInfo) {
//自定义操作
}
onVideoPlayerPlaySeries(series) {
//自定义操作
}
onVideoPlayerPlaying() {
//自定义操作
}
//...覆写其他方法
}
export default new PlayerEventListener();
2. 注册播放器事件监听者
点击查看源码
vue
...
//播放之前,注册播放器事件监听
ESPlayerManagerEventManager.addListener(PlayerEventListener)
...