-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize code size for VideoPlayer and WebView. #18231
Conversation
👍 Package size ⤵ -274 bytes, old: 5227657, new: 5227383Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -59031,16 +59031,8 @@
onEnable(): void;
onDisable(): void;
onDestroy(): void;
update(dt: number): void;
- onMetaLoaded(): void;
- onReadyToPlay(): void;
- onPlaying(): void;
- onPaused(): void;
- onStopped(): void;
- onCompleted(): void;
- onError(): void;
- onClicked(): void;
/**
* @en
* Play the clip.<br>
* Restart if already playing.<br>
@@ -59160,11 +59152,8 @@
* @param {String} str
*/
evaluateJS(str: string): void;
__preload(): void;
- onLoading(): void;
- onLoaded(): void;
- onError(...args: any[any]): void;
onEnable(): void;
onDisable(): void;
onDestroy(): void;
update(dt: number): void;
|
It seems this PR changes some interfaces. |
No one will use those interfaces, you could just review those files. this._impl.componentEventList.set(VideoPlayerEventType.META_LOADED, this.onMetaLoaded.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.READY_TO_PLAY, this.onReadyToPlay.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.PLAYING, this.onPlaying.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.PAUSED, this.onPaused.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.STOPPED, this.onStopped.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.COMPLETED, this.onCompleted.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.ERROR, this.onError.bind(this));
this._impl.componentEventList.set(VideoPlayerEventType.CLICKED, this.onClicked.bind(this)); They're callbacks set to internal module and triggered by internal module. Imagine when will a developer invoke those methods since they should be triggered internally. I guess it was just the person who developed WebView/VideoPlayer Anyway, this is just what I found while reviewing code. If some one invokes those methods directly, they're doing wrong things. |
# Conflicts: # cocos/video/video-player.ts # cocos/web-view/web-view.ts
And if developer wants to listen on these callbacks, they could use event subscription which is supported currently. private onMetaLoaded (): void {
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, VideoPlayerEventType.META_LOADED);
this.node.emit('meta-loaded', this);
}
private onReadyToPlay (): void {
if (this._playOnAwake && !this.isPlaying) { this.play(); }
ComponentEventHandler.emitEvents(this.videoPlayerEvent, this, VideoPlayerEventType.READY_TO_PLAY);
this.node.emit(VideoPlayerEventType.READY_TO_PLAY, this);
} videoComp.node.on(VideoPlayerEventType.READY_TO_PLAY, () => {
// balabala
}); |
Re: #18222
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: