From ebc2b694d1b5dc6b8a2cd2825e11f914e542cc56 Mon Sep 17 00:00:00 2001 From: Wei Jia Date: Thu, 3 Nov 2016 17:44:01 -0700 Subject: [PATCH] MediaPlayer: enable same seek modes as in MediaMetadataRetriever. Test: manually check result of mediaplayer.seekTo Bug: 32557491 Change-Id: Ib507fbfb86a24fcf9b42758e89e595a4a58d33b5 --- api/current.txt | 5 + api/system-current.txt | 5 + api/test-current.txt | 5 + media/java/android/media/MediaPlayer.java | 111 ++++++++++++++++++++-- media/jni/android_media_MediaPlayer.cpp | 8 +- 5 files changed, 123 insertions(+), 11 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8a00273ba893e..bfa926db310c8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -21325,6 +21325,7 @@ package android.media { method public void prepareAsync() throws java.lang.IllegalStateException; method public void release(); method public void reset(); + method public void seekTo(int, int) throws java.lang.IllegalStateException; method public void seekTo(int) throws java.lang.IllegalStateException; method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; @@ -21377,6 +21378,10 @@ package android.media { field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc field public static final java.lang.String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; + field public static final int SEEK_CLOSEST = 3; // 0x3 + field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 + field public static final int SEEK_NEXT_SYNC = 1; // 0x1 + field public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; // 0x1 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // 0x2 } diff --git a/api/system-current.txt b/api/system-current.txt index 3ecc8aa575c9a..fc65a8ce22507 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -22890,6 +22890,7 @@ package android.media { method public void prepareAsync() throws java.lang.IllegalStateException; method public void release(); method public void reset(); + method public void seekTo(int, int) throws java.lang.IllegalStateException; method public void seekTo(int) throws java.lang.IllegalStateException; method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; @@ -22942,6 +22943,10 @@ package android.media { field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc field public static final java.lang.String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; + field public static final int SEEK_CLOSEST = 3; // 0x3 + field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 + field public static final int SEEK_NEXT_SYNC = 1; // 0x1 + field public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; // 0x1 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // 0x2 } diff --git a/api/test-current.txt b/api/test-current.txt index 13b0c941fb173..c4d7fe00607b9 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -21406,6 +21406,7 @@ package android.media { method public void prepareAsync() throws java.lang.IllegalStateException; method public void release(); method public void reset(); + method public void seekTo(int, int) throws java.lang.IllegalStateException; method public void seekTo(int) throws java.lang.IllegalStateException; method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; @@ -21458,6 +21459,10 @@ package android.media { field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc field public static final java.lang.String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; + field public static final int SEEK_CLOSEST = 3; // 0x3 + field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 + field public static final int SEEK_NEXT_SYNC = 1; // 0x1 + field public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; // 0x1 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // 0x2 } diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 36ad90b6026cd..eff5aac0ad2d6 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -127,7 +127,7 @@ import java.lang.ref.WeakReference; * {@link #getVideoWidth()}, {@link #setAudioStreamType(int)}, * {@link #setLooping(boolean)}, * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, - * {@link #stop()}, {@link #seekTo(int)}, {@link #prepare()} or + * {@link #stop()}, {@link #seekTo(int, int)}, {@link #prepare()} or * {@link #prepareAsync()} in the Idle state for both cases. If any of these * methods is called right after a MediaPlayer object is constructed, * the user supplied callback method OnErrorListener.onError() won't be @@ -273,19 +273,22 @@ import java.lang.ref.WeakReference; * * *
  • The playback position can be adjusted with a call to - * {@link #seekTo(int)}. + * {@link #seekTo(int, int)}. *