From 49c42bc1bc62454ba80e4f3fa1205b23c2d99588 Mon Sep 17 00:00:00 2001 From: m1ga Date: Sun, 22 Jan 2023 14:23:20 +0100 Subject: [PATCH 1/3] feat(android): expose videoPlayer buffer --- .../ti/modules/titanium/media/TiPlaybackListener.java | 2 ++ .../java/ti/modules/titanium/media/TiUIVideoView.java | 6 ++++++ .../ti/modules/titanium/media/VideoPlayerProxy.java | 7 +++++++ apidoc/Titanium/Media/VideoPlayer.yml | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiPlaybackListener.java b/android/modules/media/src/java/ti/modules/titanium/media/TiPlaybackListener.java index f9d2dd4ff10..153384b49fe 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiPlaybackListener.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiPlaybackListener.java @@ -19,4 +19,6 @@ public interface TiPlaybackListener { void onSeekingBackward(); void onSeekingForward(); + + void onBuffer(int value); } diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java b/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java index 01b37392bd3..fb5a06f2e64 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java @@ -371,6 +371,12 @@ public void onSeekingForward() getPlayerProxy().onSeekingForward(); } + @Override + public void onBuffer(int value) + { + getPlayerProxy().onBuffer(value); + } + @Override public void onSeekingBackward() { diff --git a/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java b/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java index d236819bc77..8fd854f7b19 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java @@ -686,6 +686,13 @@ public void onSeekingBackward() firePlaybackState(MediaModule.VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD); } + public void onBuffer(int value) + { + KrollDict kd = new KrollDict(); + kd.put("percentage", value); + fireEvent("buffer", kd); + } + private String getActionName(int action) { switch (action) { diff --git a/apidoc/Titanium/Media/VideoPlayer.yml b/apidoc/Titanium/Media/VideoPlayer.yml index 80109ee094c..b1248591ead 100644 --- a/apidoc/Titanium/Media/VideoPlayer.yml +++ b/apidoc/Titanium/Media/VideoPlayer.yml @@ -205,6 +205,16 @@ methods: summary: Stops playing the video. events: + - name: buffer + summary: | + Fired when the video is loading/buffering. + properties: + - name: percentage + summary: Percentage of the video that is buffered/loaded. + type: Number + since: '12.1.0' + platforms: [android] + - name: complete summary: Fired when movie playback ends or a user exits playback. description: | From 309250a251d783817e4c78c0d8f984347265d4d0 Mon Sep 17 00:00:00 2001 From: m1ga Date: Sun, 22 Jan 2023 14:24:36 +0100 Subject: [PATCH 2/3] feat(android): expose videoPlayer buffer --- .../modules/media/src/java/android/widget/TiVideoView8.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/modules/media/src/java/android/widget/TiVideoView8.java b/android/modules/media/src/java/android/widget/TiVideoView8.java index 7a3a143ec48..affd0cbe1d7 100644 --- a/android/modules/media/src/java/android/widget/TiVideoView8.java +++ b/android/modules/media/src/java/android/widget/TiVideoView8.java @@ -552,6 +552,9 @@ public boolean onError(MediaPlayer mp, int framework_err, int impl_err) public void onBufferingUpdate(MediaPlayer mp, int percent) { mCurrentBufferPercentage = percent; + if (mPlaybackListener != null) { + mPlaybackListener.onBuffer(percent); + } } }; From fc100f62b5850c90b363f5175c493f6cffdede07 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Mon, 25 Dec 2023 11:48:16 +0100 Subject: [PATCH 3/3] Update apidoc/Titanium/Media/VideoPlayer.yml --- apidoc/Titanium/Media/VideoPlayer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Titanium/Media/VideoPlayer.yml b/apidoc/Titanium/Media/VideoPlayer.yml index b1248591ead..11266ccd8bd 100644 --- a/apidoc/Titanium/Media/VideoPlayer.yml +++ b/apidoc/Titanium/Media/VideoPlayer.yml @@ -212,7 +212,7 @@ events: - name: percentage summary: Percentage of the video that is buffered/loaded. type: Number - since: '12.1.0' + since: '12.3.0' platforms: [android] - name: complete