mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
update video player and web view event type (#7631)
This commit is contained in:
@@ -56,48 +56,48 @@ export enum EventType {
|
||||
* @en None
|
||||
* @zh 无
|
||||
*/
|
||||
NONE,
|
||||
NONE = 'none',
|
||||
/**
|
||||
* @en The video is playing.
|
||||
* @zh 视频播放中
|
||||
*/
|
||||
PLAYING,
|
||||
PLAYING = 'playing',
|
||||
/**
|
||||
* @en Video paused
|
||||
* @zh 视频暂停中
|
||||
*/
|
||||
PAUSED,
|
||||
PAUSED = 'paused',
|
||||
/**
|
||||
* @en Video stopped
|
||||
* @zh 视频停止中
|
||||
*/
|
||||
STOPPED,
|
||||
STOPPED = 'stopped',
|
||||
/**
|
||||
* @en End of video
|
||||
* @zh 视频播放完毕
|
||||
*/
|
||||
COMPLETED,
|
||||
COMPLETED = 'completed',
|
||||
/**
|
||||
* @en Video metadata loading complete
|
||||
* @zh 视频元数据加载完毕
|
||||
*/
|
||||
META_LOADED,
|
||||
META_LOADED = 'meta-loaded',
|
||||
/**
|
||||
* @en The video is ready to play when loaded
|
||||
* @zh 视频加载完毕可播放
|
||||
*/
|
||||
READY_TO_PLAY,
|
||||
READY_TO_PLAY = 'ready-to-play',
|
||||
/**
|
||||
* @en Video Trigger Error
|
||||
* @zh 处理视频时触发的错误
|
||||
*/
|
||||
ERROR,
|
||||
ERROR = 'error',
|
||||
|
||||
/**
|
||||
* @en Video clicked
|
||||
* @zh 视频被点击
|
||||
*/
|
||||
CLICKED,
|
||||
CLICKED = 'clicked',
|
||||
}
|
||||
|
||||
export enum READY_STATE {
|
||||
|
||||
@@ -425,32 +425,32 @@ export class VideoPlayer extends Component {
|
||||
public onReadyToPlay () {
|
||||
if (this._playOnAwake && !this.isPlaying) { this.play(); }
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.READY_TO_PLAY);
|
||||
this.node.emit('ready-to-play', this);
|
||||
this.node.emit(EventType.READY_TO_PLAY, this);
|
||||
}
|
||||
|
||||
public onPlaying () {
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PLAYING);
|
||||
this.node.emit('playing', this);
|
||||
this.node.emit(EventType.PLAYING, this);
|
||||
}
|
||||
|
||||
public onPasued () {
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PAUSED);
|
||||
this.node.emit('paused', this);
|
||||
this.node.emit(EventType.PAUSED, this);
|
||||
}
|
||||
|
||||
public onStopped () {
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.STOPPED);
|
||||
this.node.emit('stopped', this);
|
||||
this.node.emit(EventType.STOPPED, this);
|
||||
}
|
||||
|
||||
public onCompleted () {
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.COMPLETED);
|
||||
this.node.emit('completed', this);
|
||||
this.node.emit(EventType.COMPLETED, this);
|
||||
}
|
||||
|
||||
public onError () {
|
||||
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, EventType.ERROR);
|
||||
this.node.emit('error', this);
|
||||
this.node.emit(EventType.ERROR, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,20 +33,20 @@ export enum EventType {
|
||||
* @en None
|
||||
* @zh 无
|
||||
*/
|
||||
NONE,
|
||||
NONE = 'none',
|
||||
/**
|
||||
* @en Web page Load completed.
|
||||
* @zh 网页加载完成
|
||||
*/
|
||||
LOADING,
|
||||
LOADING = 'loading',
|
||||
/**
|
||||
* @en Web page is loading.
|
||||
* @zh 网页加载中
|
||||
*/
|
||||
LOADED,
|
||||
LOADED = 'loaded',
|
||||
/**
|
||||
* @en Web page error occurs when loading.
|
||||
* @zh 网页加载出错
|
||||
*/
|
||||
ERROR,
|
||||
ERROR = 'error',
|
||||
}
|
||||
|
||||
@@ -180,17 +180,17 @@ export class WebView extends Component {
|
||||
|
||||
onLoading () {
|
||||
ComponentEventHandler.emitEvents(this.webviewEvents, this, EventType.LOADING);
|
||||
this.node.emit('loading', this);
|
||||
this.node.emit(EventType.LOADING, this);
|
||||
}
|
||||
|
||||
onLoaded () {
|
||||
ComponentEventHandler.emitEvents(this.webviewEvents, this, EventType.LOADED);
|
||||
this.node.emit('loaded', this);
|
||||
this.node.emit(EventType.LOADED, this);
|
||||
}
|
||||
|
||||
onError () {
|
||||
ComponentEventHandler.emitEvents(this.webviewEvents, this, EventType.ERROR);
|
||||
this.node.emit('error', this);
|
||||
this.node.emit(EventType.ERROR, this);
|
||||
}
|
||||
|
||||
public onEnable () {
|
||||
|
||||
Reference in New Issue
Block a user