Merge "MediaController2: Match APIs with MediaPlayerBase" into pi-dev

am: c4f56a6be5

Change-Id: Ifd0c8a4c07ee3ccb7b377cff486e67801750a7ee
This commit is contained in:
Jaewan Kim
2018-03-26 02:26:14 +00:00
committed by android-build-merger
2 changed files with 32 additions and 12 deletions

View File

@@ -16,6 +16,8 @@
package android.media; package android.media;
import static android.media.MediaPlayerBase.BUFFERING_STATE_UNKNOWN;
import android.annotation.CallbackExecutor; import android.annotation.CallbackExecutor;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
@@ -166,13 +168,16 @@ public class MediaController2 implements AutoCloseable {
float speed) { } float speed) { }
/** /**
* Called when the player's buffering position * Called to report buffering events for a data source.
* <p>
* Use {@link #getBufferedPosition()} for current buffering position.
* *
* @param controller the controller for this event * @param controller the controller for this event
* @param positionMs buffering position in millis * @param item the media item for which buffering is happening.
* @param state the new buffering state.
*/ */
public void onBufferedPositionChanged(@NonNull MediaController2 controller, public void onBufferingStateChanged(@NonNull MediaController2 controller,
long positionMs) { } @NonNull MediaItem2 item, @MediaPlayerBase.BuffState int state) { }
/** /**
* Called when a error from * Called when a error from
@@ -193,7 +198,7 @@ public class MediaController2 implements AutoCloseable {
* @param controller the controller for this event * @param controller the controller for this event
* @param item new item * @param item new item
* @see #onPositionChanged(MediaController2, long, long) * @see #onPositionChanged(MediaController2, long, long)
* @see #onBufferedPositionChanged(MediaController2, long) * @see #onBufferingStateChanged(MediaController2, MediaItem2, int)
*/ */
// TODO(jaewan): Use this (b/74316764) // TODO(jaewan): Use this (b/74316764)
public void onCurrentMediaItemChanged(@NonNull MediaController2 controller, public void onCurrentMediaItemChanged(@NonNull MediaController2 controller,
@@ -443,9 +448,11 @@ public class MediaController2 implements AutoCloseable {
} }
/** /**
* Revisit this API later.
* @hide * @hide
*/ */
public void skipForward() { public void skipForward() {
// TODO(jaewan): (Post-P) Discuss this API later.
// To match with KEYCODE_MEDIA_SKIP_FORWARD // To match with KEYCODE_MEDIA_SKIP_FORWARD
} }
@@ -453,6 +460,7 @@ public class MediaController2 implements AutoCloseable {
* @hide * @hide
*/ */
public void skipBackward() { public void skipBackward() {
// TODO(jaewan): (Post-P) Discuss this API later.
// To match with KEYCODE_MEDIA_SKIP_BACKWARD // To match with KEYCODE_MEDIA_SKIP_BACKWARD
} }
@@ -598,16 +606,15 @@ public class MediaController2 implements AutoCloseable {
} }
/** /**
* Get the lastly cached position from * Gets the current playback position.
* {@link ControllerCallback#onPositionChanged(MediaController2, long, long)}.
* <p> * <p>
* This returns the calculated value of the position, based on the difference between the * This returns the calculated value of the position, based on the difference between the
* update time and current time. * update time and current time.
* *
* @return position * @return position
*/ */
public long getPosition() { public long getCurrentPosition() {
return mProvider.getPosition_impl(); return mProvider.getCurrentPosition_impl();
} }
/** /**
@@ -627,9 +634,22 @@ public class MediaController2 implements AutoCloseable {
// TODO(jaewan): implement this (b/74093080) // TODO(jaewan): implement this (b/74093080)
} }
/** /**
* Get the lastly cached buffered position from * Gets the current buffering state of the player.
* {@link ControllerCallback#onBufferedPositionChanged(MediaController2, long)}. * During buffering, see {@link #getBufferedPosition()} for the quantifying the amount already
* buffered.
* @return the buffering state.
*/
public @MediaPlayerBase.BuffState int getBufferingState() {
// TODO(jaewan): Implement.
return BUFFERING_STATE_UNKNOWN;
}
/**
* Gets the lastly cached buffered position from the session when
* {@link ControllerCallback#onBufferingStateChanged(MediaController2, MediaItem2, int)} is
* called.
* *
* @return buffering position in millis * @return buffering position in millis
*/ */

View File

@@ -65,7 +65,7 @@ public interface MediaController2Provider extends TransportControlProvider {
void removePlaylistItem_impl(MediaItem2 item); void removePlaylistItem_impl(MediaItem2 item);
int getPlayerState_impl(); int getPlayerState_impl();
long getPosition_impl(); long getCurrentPosition_impl();
float getPlaybackSpeed_impl(); float getPlaybackSpeed_impl();
long getBufferedPosition_impl(); long getBufferedPosition_impl();
MediaItem2 getCurrentMediaItem_impl(); MediaItem2 getCurrentMediaItem_impl();