Commit b7666df2 by olly Committed by Ian Baker

Add Player play and pause convenience methods

PiperOrigin-RevId: 283744017
parent e54b493b
......@@ -24,6 +24,7 @@
* Make media session connector dispatch ACTION_SET_CAPTIONING_ENABLED.
* Add support for position and overlapping start/end times in SSA/ASS subtitles
([#6320](https://github.com/google/ExoPlayer/issues/6320)).
* Add `play` and `pause` methods to `Player`.
* Upgrade Truth dependency from 0.44 to 1.0.
### 2.11.0 (not yet released) ###
......
......@@ -28,6 +28,16 @@ public abstract class BasePlayer implements Player {
}
@Override
public final void play() {
setPlayWhenReady(true);
}
@Override
public final void pause() {
setPlayWhenReady(false);
}
@Override
public final boolean isPlaying() {
return getPlaybackState() == Player.STATE_READY
&& getPlayWhenReady()
......
......@@ -726,10 +726,18 @@ public interface Player {
ExoPlaybackException getPlaybackError();
/**
* Resumes playback as soon as {@link #getPlaybackState()} == {@link #STATE_READY}. Equivalent to
* {@code setPlayWhenReady(true)}.
*/
void play();
/** Pauses playback. Equivalent to {@code setPlayWhenReady(false)}. */
void pause();
/**
* Sets whether playback should proceed when {@link #getPlaybackState()} == {@link #STATE_READY}.
* <p>
* If the player is already in the ready state then this method can be used to pause and resume
* playback.
*
* <p>If the player is already in the ready state then this method pauses and resumes playback.
*
* @param playWhenReady Whether playback should proceed when ready.
*/
......@@ -857,8 +865,8 @@ public interface Player {
PlaybackParameters getPlaybackParameters();
/**
* Stops playback without resetting the player. Use {@code setPlayWhenReady(false)} rather than
* this method if the intention is to pause playback.
* Stops playback without resetting the player. Use {@link #pause()} rather than this method if
* the intention is to pause playback.
*
* <p>Calling this method will cause the playback state to transition to {@link #STATE_IDLE}. The
* player instance can still be used, and {@link #release()} must still be called on the player if
......@@ -869,8 +877,8 @@ public interface Player {
void stop();
/**
* Stops playback and optionally resets the player. Use {@code setPlayWhenReady(false)} rather
* than this method if the intention is to pause playback.
* Stops playback and optionally resets the player. Use {@link #pause()} rather than this method
* if the intention is to pause playback.
*
* <p>Calling this method will cause the playback state to transition to {@link #STATE_IDLE}. The
* player instance can still be used, and {@link #release()} must still be called on the player if
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment