Skip to content

Commit fcef441

Browse files
committed
Added onReadyForDisplay to web/dom
1 parent e5b5bbe commit fcef441

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,9 @@ Payload: none
962962

963963
* iOS: [readyForDisplay](https://developer.apple.com/documentation/avkit/avplayerviewcontroller/1615830-readyfordisplay?language=objc)
964964
* Android: [MEDIA_INFO_VIDEO_RENDERING_START](https://developer.android.com/reference/android/media/MediaPlayer#MEDIA_INFO_VIDEO_RENDERING_START)
965+
* Android ExoPlayer [STATE_READY](https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/Player.html#STATE_READY)
965966

966-
Platforms: all
967+
Platforms: Android ExoPlayer, Android MediaPlayer, iOS, Web
967968

968969
#### onPictureInPictureStatusChanged
969970
Callback function that is called when picture in picture becomes active or inactive.

dom/RCTVideo.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class RCTVideo extends RCTView {
3737
this.videoElement = this.initializeVideoElement();
3838
this.videoElement.addEventListener("ended", this.onEnd);
3939
this.videoElement.addEventListener("loadeddata", this.onLoad);
40+
this.videoElement.addEventListener("canplay", this.onReadyForDisplay);
4041
this.videoElement.addEventListener("loadstart", this.onLoadStart);
4142
this.videoElement.addEventListener("pause", this.onPause);
4243
this.videoElement.addEventListener("play", this.onPlay);
@@ -51,6 +52,7 @@ class RCTVideo extends RCTView {
5152
detachFromView(view: UIView) {
5253
this.videoElement.removeEventListener("ended", this.onEnd);
5354
this.videoElement.removeEventListener("loadeddata", this.onLoad);
55+
this.videoElement.removeEventListener("canplay", this.onReadyForDisplay);
5456
this.videoElement.removeEventListener("loadstart", this.onLoadStart);
5557
this.videoElement.removeEventListener("pause", this.onPause);
5658
this.videoElement.removeEventListener("play", this.onPlay);
@@ -203,6 +205,10 @@ class RCTVideo extends RCTView {
203205
this.sendEvent("topVideoLoad", payload);
204206
}
205207

208+
onReadyForDisplay = () => {
209+
this.sendEvent("onReadyForDisplay");
210+
}
211+
206212
onLoadStart = () => {
207213
const src = this.videoElement.currentSrc;
208214
const payload = {

0 commit comments

Comments
 (0)