summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mira <samuel.mira@qt.io>2021-11-08 16:09:29 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-09 09:42:10 +0000
commit51667b5b214d5d29589f44f4d65428924dc064ce (patch)
treee92d4129d55ae9689ca65776a640ac6deebfa5f7
parenta85f80ceafabaa2913e7a857024bdac808892129 (diff)
downloadqtmultimedia-51667b5b214d5d29589f44f4d65428924dc064ce.tar.gz
Change Android MediaPlayer SeekTo to the Closest Frame
The default behavior for seekTo in Android is to seek the previous Sync Frame (the previous I-frame), disregarding the provided time. Depending on the video file, this can be a 5-second difference. This patch will change this behavior for the closest frame of the provided time. It is still not the exact time, but it will be closer than before. This change is only possible for Android API > 26. Below that will continue to seek to the previous Sync Frame. Fixes: QTBUG-97415 Change-Id: I9e698b023d30c0e527180198970430f39fda1f93 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Pekka Gehör <pekka.gehor@qt.io> (cherry picked from commit 0c1bb90691780703eabc7ed1954d6b49fe5da580) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/multimedia/QtAndroidMediaPlayer.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAndroidMediaPlayer.java b/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAndroidMediaPlayer.java
index 1ec250d47..ce5dd5008 100644
--- a/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAndroidMediaPlayer.java
+++ b/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAndroidMediaPlayer.java
@@ -374,13 +374,18 @@ public class QtAndroidMediaPlayer
}
try {
- mMediaPlayer.seekTo(msec);
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ // seekTo to closest frame of the provided msec is only available for devices
+ // with api level over 26
+ mMediaPlayer.seekTo(msec, MediaPlayer.SEEK_CLOSEST);
+ } else {
+ mMediaPlayer.seekTo(msec);
+ }
} catch (final IllegalStateException exception) {
Log.w(TAG, exception);
}
}
-
public boolean isPlaying()
{
boolean playing = false;