MediaSession2: Implement getPlayerState/Position/BufferedPosition

am: 78e4f84f04

Change-Id: I58c1d7c12900ed0542db9a930ecd8be1461a99eb
This commit is contained in:
Hyundo Moon
2018-03-16 09:47:42 +00:00
committed by android-build-merger
3 changed files with 18 additions and 17 deletions

View File

@@ -132,8 +132,8 @@ public abstract class MediaPlayerBase implements AutoCloseable {
public static final long UNKNOWN_TIME = -1;
/**
* Returns the current playback head position.
* @return the current play position in ms, or {@link #UNKNOWN_TIME} if unknown.
* Gets the current playback head position.
* @return the current playback position in ms, or {@link #UNKNOWN_TIME} if unknown.
*/
public long getCurrentPosition() { return UNKNOWN_TIME; }
@@ -144,8 +144,8 @@ public abstract class MediaPlayerBase implements AutoCloseable {
public long getDuration() { return UNKNOWN_TIME; }
/**
* Returns the duration of the current data source, or {@link #UNKNOWN_TIME} if unknown.
* @return the duration in ms, or {@link #UNKNOWN_TIME}.
* Gets the buffered position of current playback, or {@link #UNKNOWN_TIME} if unknown.
* @return the buffered position in ms, or {@link #UNKNOWN_TIME}.
*/
public long getBufferedPosition() { return UNKNOWN_TIME; }

View File

@@ -1465,39 +1465,37 @@ public class MediaSession2 implements AutoCloseable {
}
/**
* Get the player state.
* Gets the current player state.
*
* @return player state
* @return the current player state
* @hide
*/
// TODO(jaewan): Unhide (b/74578458)
public @PlayerState int getPlayerState() {
// TODO(jaewan): implement this (b/74578458)
return PLAYER_STATE_IDLE;
return mProvider.getPlayerState_impl();
}
/**
* Get the current position.
* Gets the current position.
*
* @return position
* @return the current playback position in ms, or {@link MediaPlayerBase#UNKNOWN_TIME} if
* unknown.
* @hide
*/
// TODO(jaewan): Unhide (b/74578458)
public long getCurrentPosition() {
// TODO(jaewan): implement this (b/74578458)
return -1;
public long getPosition() {
return mProvider.getPosition_impl();
}
/**
* Get the buffered position.
* Gets the buffered position, or {@link MediaPlayerBase#UNKNOWN_TIME} if unknown.
*
* @return buffered position
* @return the buffered position in ms, or {@link MediaPlayerBase#UNKNOWN_TIME}.
* @hide
*/
// TODO(jaewan): Unhide (b/74578458)
public long getBufferedPosition() {
// TODO(jaewan): implement this (b/74578458)
return -1;
return mProvider.getBufferedPosition_impl();
}
/**

View File

@@ -65,6 +65,9 @@ public interface MediaSession2Provider extends TransportControlProvider {
void setPlaylist_impl(List<MediaItem2> list, MediaMetadata2 metadata);
MediaItem2 getCurrentPlaylistItem_impl();
void notifyError_impl(int errorCode, Bundle extras);
int getPlayerState_impl();
long getPosition_impl();
long getBufferedPosition_impl();
interface CommandProvider {
int getCommandCode_impl();