MediaController2: Add fastForward() / rewind()

Following CLs are included
  - Add MediaController2#fastForward() / rewind()
  - Add MediaSession2.SessionCallback#onFastForward() / rewind()

Bug: 74724709
Test: Build
Change-Id: I0dd2b6c21931df937006ae26011ea9538720afee
This commit is contained in:
Jaewan Kim
2018-03-19 23:09:00 +09:00
parent cdc9d9008b
commit ab715ec20b
5 changed files with 22 additions and 58 deletions

View File

@@ -423,16 +423,14 @@ public class MediaController2 implements AutoCloseable {
}
/**
* Start fast forwarding. If playback is already fast forwarding this
* may increase the rate.
* Fast forwards playback. If playback is already fast forwarding this may increase the rate.
*/
public void fastForward() {
mProvider.fastForward_impl();
}
/**
* Start rewinding. If playback is already rewinding this may increase
* the rate.
* Rewinds playback. If playback is already rewinding this may increase the rate.
*/
public void rewind() {
mProvider.rewind_impl();

View File

@@ -130,33 +130,6 @@ public abstract class MediaPlayerBase implements AutoCloseable {
*/
public abstract void seekTo(long pos);
/**
* Fast forwards playback. If playback is already fast forwarding this may increase the rate.
* <p>
* Default implementation sets the playback speed to the 2.0f
* @see #setPlaybackSpeed(float)
* @hide
*/
// TODO(jaewan): Unhide (b/74724709)
public void fastForward() {
setPlaybackSpeed(2.0f);
}
/**
* Rewinds playback. If playback is already rewinding this may increase the rate.
* <p>
* Default implementation sets the playback speed to the -1.0f if
* {@link #isReversePlaybackSupported()} returns {@code true}.
* @see #setPlaybackSpeed(float)
* @hide
*/
// TODO(jaewan): Unhide (b/74724709)
public void rewind() {
if (isReversePlaybackSupported()) {
setPlaybackSpeed(-1.0f);
}
}
public static final long UNKNOWN_TIME = -1;
/**

View File

@@ -142,20 +142,13 @@ public class MediaSession2 implements AutoCloseable {
/**
* Command code for {@link MediaController2#fastForward()}.
* <p>
* This is transport control command. Command would be sent directly to the player if the
* session doesn't reject the request through the
* {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
public static final int COMMAND_CODE_PLAYBACK_FAST_FORWARD = 7;
public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 7;
/**
* Command code for {@link MediaController2#rewind()}.
* <p>
* Command would be sent directly to the player if the session doesn't reject the request
* through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
public static final int COMMAND_CODE_PLAYBACK_REWIND = 8;
public static final int COMMAND_CODE_SESSION_REWIND = 8;
/**
* Command code for {@link MediaController2#seekTo(long)}.
@@ -634,8 +627,8 @@ public class MediaSession2 implements AutoCloseable {
* @see #COMMAND_CODE_PLAYLIST_SKIP_NEXT_ITEM
* @see #COMMAND_CODE_PLAYLIST_SKIP_PREV_ITEM
* @see #COMMAND_CODE_PLAYBACK_PREPARE
* @see #COMMAND_CODE_PLAYBACK_FAST_FORWARD
* @see #COMMAND_CODE_PLAYBACK_REWIND
* @see #COMMAND_CODE_SESSION_FAST_FORWARD
* @see #COMMAND_CODE_SESSION_REWIND
* @see #COMMAND_CODE_PLAYBACK_SEEK_TO
* @see #COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM
* @see #COMMAND_CODE_PLAYLIST_ADD_ITEM
@@ -795,6 +788,20 @@ public class MediaSession2 implements AutoCloseable {
public void onPrepareFromUri(@NonNull MediaSession2 session,
@NonNull ControllerInfo controller, @NonNull Uri uri, @Nullable Bundle extras) { }
/**
* Called when a controller called {@link MediaController2#fastForward()}
*
* @param session the session for this event
*/
public void onFastForward(@NonNull MediaSession2 session) { }
/**
* Called when a controller called {@link MediaController2#rewind()}
*
* @param session the session for this event
*/
public void onRewind(@NonNull MediaSession2 session) { }
/**
* Called when the player's current playing item is changed
* <p>
@@ -1435,20 +1442,6 @@ public class MediaSession2 implements AutoCloseable {
mProvider.prepare_impl();
}
/**
* Fast forwards playback. If playback is already fast forwarding this may increase the rate.
*/
public void fastForward() {
mProvider.fastForward_impl();
}
/**
* Rewinds playback. If playback is already rewinding this may increase the rate.
*/
public void rewind() {
mProvider.rewind_impl();
}
/**
* Move to a new location in the media stream.
*

View File

@@ -52,6 +52,8 @@ public interface MediaController2Provider extends TransportControlProvider {
void playFromSearch_impl(String query, Bundle extras);
void playFromUri_impl(Uri uri, Bundle extras);
void playFromMediaId_impl(String mediaId, Bundle extras);
void fastForward_impl();
void rewind_impl();
void setRating_impl(String mediaId, Rating2 rating);
void sendCustomCommand_impl(Command command, Bundle args, ResultReceiver cb);

View File

@@ -29,8 +29,6 @@ public interface TransportControlProvider {
void skipToNextItem_impl();
void prepare_impl();
void fastForward_impl();
void rewind_impl();
void seekTo_impl(long pos);
void skipToPlaylistItem_impl(MediaItem2 item);