Cleanup recent merged pull requests

This commit is contained in:
Oliver Woodman 2018-08-16 17:02:08 +01:00
parent 071155d219
commit 32bd69d4b2
4 changed files with 66 additions and 63 deletions

View File

@ -44,9 +44,10 @@
on ExoPlayer via its source code rather than an AAR may need to add on ExoPlayer via its source code rather than an AAR may need to add
`compileOptions { targetCompatibility JavaVersion.VERSION_1_8 }` to their `compileOptions { targetCompatibility JavaVersion.VERSION_1_8 }` to their
gradle settings to ensure bytecode compatibility. gradle settings to ensure bytecode compatibility.
* Add support for lazy preparation of playlist media sources in * ConcatenatingMediaSource:
`ConcatenatingMediaSource` * Add support for lazy preparation of playlist media sources
([#3972](https://github.com/google/ExoPlayer/issues/3972)). ([#3972](https://github.com/google/ExoPlayer/issues/3972)).
* Add support for range removal with `removeMediaSourceRange` methods.
* `BandwidthMeter` management: * `BandwidthMeter` management:
* Pass `BandwidthMeter` directly to `ExoPlayerFactory` instead of * Pass `BandwidthMeter` directly to `ExoPlayerFactory` instead of
`TrackSelection.Factory` and `DataSource.Factory`. May also be omitted to `TrackSelection.Factory` and `DataSource.Factory`. May also be omitted to
@ -108,6 +109,9 @@
* IMA: Improve handling of consecutive empty ad groups * IMA: Improve handling of consecutive empty ad groups
([#4030](https://github.com/google/ExoPlayer/issues/4030)), ([#4030](https://github.com/google/ExoPlayer/issues/4030)),
([#4280](https://github.com/google/ExoPlayer/issues/4280)). ([#4280](https://github.com/google/ExoPlayer/issues/4280)).
* Add option to show buffering view when playWhenReady is false
([#4304](https://github.com/google/ExoPlayer/issues/4304)).
* Allow any `Drawable` to be used as `PlayerView` default artwork.
### 2.8.3 ### ### 2.8.3 ###

View File

@ -265,8 +265,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
* <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int, * <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int,
* int)} instead. * int)} instead.
* *
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use * <p>Note: If you want to remove a set of contiguous sources, it's preferable to use {@link
* {@link #removeMediaSourceRange(int, int)} instead. * #removeMediaSourceRange(int, int)} instead.
* *
* @param index The index at which the media source will be removed. This index must be in the * @param index The index at which the media source will be removed. This index must be in the
* range of 0 &lt;= index &lt; {@link #getSize()}. * range of 0 &lt;= index &lt; {@link #getSize()}.
@ -281,8 +281,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
* <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int, * <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int,
* int, Runnable)} instead. * int, Runnable)} instead.
* *
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use * <p>Note: If you want to remove a set of contiguous sources, it's preferable to use {@link
* {@link #removeMediaSourceRange(int, int, Runnable)} instead. * #removeMediaSourceRange(int, int, Runnable)} instead.
* *
* @param index The index at which the media source will be removed. This index must be in the * @param index The index at which the media source will be removed. This index must be in the
* range of 0 &lt;= index &lt; {@link #getSize()}. * range of 0 &lt;= index &lt; {@link #getSize()}.
@ -307,15 +307,15 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
* Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index * Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index
* (included) and a final index (excluded). * (included) and a final index (excluded).
* *
* <p>Note: when specified range is empty, no actual media source is removed and no exception * <p>Note: when specified range is empty, no actual media source is removed and no exception is
* is thrown. * thrown.
* *
* @param fromIndex The initial range index, pointing to the first media source that will be * @param fromIndex The initial range index, pointing to the first media source that will be
* removed. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}. * removed. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
* @param toIndex The final range index, pointing to the first media source that will be left * @param toIndex The final range index, pointing to the first media source that will be left
* untouched. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}. * untouched. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; * @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; 0,
* 0, {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex} * {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
*/ */
public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex) { public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex) {
removeMediaSourceRange(fromIndex, toIndex, null); removeMediaSourceRange(fromIndex, toIndex, null);
@ -325,8 +325,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
* Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index * Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index
* (included) and a final index (excluded), and executes a custom action on completion. * (included) and a final index (excluded), and executes a custom action on completion.
* *
* <p>Note: when specified range is empty, no actual media source is removed and no exception * <p>Note: when specified range is empty, no actual media source is removed and no exception is
* is thrown. * thrown.
* *
* @param fromIndex The initial range index, pointing to the first media source that will be * @param fromIndex The initial range index, pointing to the first media source that will be
* removed. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}. * removed. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
@ -334,11 +334,11 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
* untouched. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}. * untouched. This index must be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
* @param actionOnCompletion A {@link Runnable} which is executed immediately after the media * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
* source range has been removed from the playlist. * source range has been removed from the playlist.
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; * @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; 0,
* 0, {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex} * {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
*/ */
public final synchronized void removeMediaSourceRange( public final synchronized void removeMediaSourceRange(
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) { int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) {
Util.removeRange(mediaSourcesPublic, fromIndex, toIndex); Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
if (fromIndex == toIndex) { if (fromIndex == toIndex) {
if (actionOnCompletion != null) { if (actionOnCompletion != null) {

View File

@ -37,8 +37,8 @@ import java.util.regex.Pattern;
/** /**
* A special purpose extractor for WebVTT content in HLS. * A special purpose extractor for WebVTT content in HLS.
* <p> *
* This extractor passes through non-empty WebVTT files untouched, however derives the correct * <p>This extractor passes through non-empty WebVTT files untouched, however derives the correct
* sample timestamp for each by sniffing the X-TIMESTAMP-MAP header along with the start timestamp * sample timestamp for each by sniffing the X-TIMESTAMP-MAP header along with the start timestamp
* of the first cue header. Empty WebVTT files are not passed through, since it's not possible to * of the first cue header. Empty WebVTT files are not passed through, since it's not possible to
* derive a sample timestamp in this case. * derive a sample timestamp in this case.

View File

@ -25,9 +25,9 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.IntDef;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
@ -89,7 +89,7 @@ import java.util.List;
* <li><b>{@code default_artwork}</b> - Default artwork to use if no artwork available in audio * <li><b>{@code default_artwork}</b> - Default artwork to use if no artwork available in audio
* streams. * streams.
* <ul> * <ul>
* <li>Corresponding method: {@link #setDefaultArtwork(Bitmap)} * <li>Corresponding method: {@link #setDefaultArtwork(Drawable)}
* <li>Default: {@code null} * <li>Default: {@code null}
* </ul> * </ul>
* <li><b>{@code use_controller}</b> - Whether the playback controls can be shown. * <li><b>{@code use_controller}</b> - Whether the playback controls can be shown.
@ -116,10 +116,10 @@ import java.util.List;
* <li>Default: {@code true} * <li>Default: {@code true}
* </ul> * </ul>
* <li><b>{@code show_buffering}</b> - Whether the buffering spinner is displayed when the player * <li><b>{@code show_buffering}</b> - Whether the buffering spinner is displayed when the player
* is buffering. * is buffering. Valid values are {@code never}, {@code when_playing} and {@code always}.
* <ul> * <ul>
* <li>Corresponding method: {@link #setShowBuffering(boolean)} * <li>Corresponding method: {@link #setShowBuffering(int)}
* <li>Default: {@code false} * <li>Default: {@code never}
* </ul> * </ul>
* <li><b>{@code resize_mode}</b> - Controls how video and album art is resized within the view. * <li><b>{@code resize_mode}</b> - Controls how video and album art is resized within the view.
* Valid values are {@code fit}, {@code fixed_width}, {@code fixed_height} and {@code fill}. * Valid values are {@code fit}, {@code fixed_width}, {@code fixed_height} and {@code fill}.
@ -243,13 +243,22 @@ public class PlayerView extends FrameLayout {
private static final int SURFACE_TYPE_TEXTURE_VIEW = 2; private static final int SURFACE_TYPE_TEXTURE_VIEW = 2;
private static final int SURFACE_TYPE_MONO360_VIEW = 3; private static final int SURFACE_TYPE_MONO360_VIEW = 3;
public static final int SHOW_BUFFERING_NEVER = 0; /** Determines when the buffering view is shown. */
public static final int SHOW_BUFFERING_ALWAYS = 1;
public static final int SHOW_BUFFERING_WHEN_PLAYING = 2;
@IntDef({SHOW_BUFFERING_NEVER, SHOW_BUFFERING_WHEN_PLAYING, SHOW_BUFFERING_ALWAYS}) @IntDef({SHOW_BUFFERING_NEVER, SHOW_BUFFERING_WHEN_PLAYING, SHOW_BUFFERING_ALWAYS})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface ShowBuffering {} public @interface ShowBuffering {}
/** The buffering view is never shown. */
public static final int SHOW_BUFFERING_NEVER = 0;
/**
* The buffering view is shown when the player is in the {@link Player#STATE_BUFFERING buffering}
* state and {@link Player#getPlayWhenReady() playWhenReady} is {@code true}.
*/
public static final int SHOW_BUFFERING_WHEN_PLAYING = 1;
/**
* The buffering view is always shown when the player is in the {@link Player#STATE_BUFFERING
* buffering} state.
*/
public static final int SHOW_BUFFERING_ALWAYS = 2;
private final AspectRatioFrameLayout contentFrame; private final AspectRatioFrameLayout contentFrame;
private final View shutterView; private final View shutterView;
@ -265,7 +274,7 @@ public class PlayerView extends FrameLayout {
private Player player; private Player player;
private boolean useController; private boolean useController;
private boolean useArtwork; private boolean useArtwork;
private Drawable defaultArtwork; private @Nullable Drawable defaultArtwork;
private @ShowBuffering int showBuffering; private @ShowBuffering int showBuffering;
private boolean keepContentOnPlayerReset; private boolean keepContentOnPlayerReset;
private @Nullable ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider; private @Nullable ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
@ -598,8 +607,9 @@ public class PlayerView extends FrameLayout {
* @deprecated use (@link {@link #setDefaultArtwork(Drawable)} instead. * @deprecated use (@link {@link #setDefaultArtwork(Drawable)} instead.
*/ */
@Deprecated @Deprecated
public void setDefaultArtwork(Bitmap defaultArtwork) { public void setDefaultArtwork(@Nullable Bitmap defaultArtwork) {
setDefaultArtwork(new BitmapDrawable(getResources(), defaultArtwork)); setDefaultArtwork(
defaultArtwork == null ? null : new BitmapDrawable(getResources(), defaultArtwork));
} }
/** /**
@ -608,7 +618,7 @@ public class PlayerView extends FrameLayout {
* *
* @param defaultArtwork the default artwork to display * @param defaultArtwork the default artwork to display
*/ */
public void setDefaultArtwork(Drawable defaultArtwork) { public void setDefaultArtwork(@Nullable Drawable defaultArtwork) {
if (this.defaultArtwork != defaultArtwork) { if (this.defaultArtwork != defaultArtwork) {
this.defaultArtwork = defaultArtwork; this.defaultArtwork = defaultArtwork;
updateForCurrentTrackSelections(/* isNewPlayer= */ false); updateForCurrentTrackSelections(/* isNewPlayer= */ false);
@ -682,7 +692,6 @@ public class PlayerView extends FrameLayout {
* buffering spinner is not displayed by default. * buffering spinner is not displayed by default.
* *
* @deprecated Use {@link #setShowBuffering(int)} * @deprecated Use {@link #setShowBuffering(int)}
*
* @param showBuffering Whether the buffering icon is displayed * @param showBuffering Whether the buffering icon is displayed
*/ */
@Deprecated @Deprecated
@ -692,15 +701,11 @@ public class PlayerView extends FrameLayout {
/** /**
* Sets whether a buffering spinner is displayed when the player is in the buffering state. The * Sets whether a buffering spinner is displayed when the player is in the buffering state. The
* buffering spinner is not displayed by default (initial value {@link #SHOW_BUFFERING_NEVER}) * buffering spinner is not displayed by default.
* *
* <p><ul> * @param showBuffering The mode that defines when the buffering spinner is displayed. One of
* <li>{@link #SHOW_BUFFERING_ALWAYS} displayed always when buffering * {@link #SHOW_BUFFERING_NEVER}, {@link #SHOW_BUFFERING_WHEN_PLAYING} and
* <li>{@link #SHOW_BUFFERING_NEVER} not displayed at all * {@link #SHOW_BUFFERING_ALWAYS}.
* <li>{@link #SHOW_BUFFERING_WHEN_PLAYING} displayed only when playing and buffering
* </ul></p>
*
* @param showBuffering Buffering strategy that defines when the buffering icon is displayed
*/ */
public void setShowBuffering(@ShowBuffering int showBuffering) { public void setShowBuffering(@ShowBuffering int showBuffering) {
if (this.showBuffering != showBuffering) { if (this.showBuffering != showBuffering) {
@ -1153,14 +1158,20 @@ public class PlayerView extends FrameLayout {
return false; return false;
} }
private boolean setDrawableArtwork(Drawable drawable) { private boolean setDrawableArtwork(@Nullable Drawable drawable) {
if(drawable != null) { if (drawable != null) {
artworkView.setImageDrawable(drawable); int drawableWidth = drawable.getIntrinsicWidth();
if(contentFrame != null) { int drawableHeight = drawable.getIntrinsicHeight();
contentFrame.setAspectRatio(0); if (drawableWidth > 0 && drawableHeight > 0) {
if (contentFrame != null) {
contentFrame.setAspectRatio((float) drawableWidth / drawableHeight);
}
artworkView.setImageDrawable(drawable);
artworkView.setVisibility(VISIBLE);
return true;
} }
} }
return true; return false;
} }
private void hideArtwork() { private void hideArtwork() {
@ -1178,23 +1189,11 @@ public class PlayerView extends FrameLayout {
private void updateBuffering() { private void updateBuffering() {
if (bufferingView != null) { if (bufferingView != null) {
boolean showBufferingSpinner =
boolean showBufferingSpinner = false; player != null
&& player.getPlaybackState() == Player.STATE_BUFFERING
if (player != null && player.getPlaybackState() == Player.STATE_BUFFERING) { && (showBuffering == SHOW_BUFFERING_ALWAYS
switch (showBuffering) { || (showBuffering == SHOW_BUFFERING_WHEN_PLAYING && player.getPlayWhenReady()));
case SHOW_BUFFERING_ALWAYS:
showBufferingSpinner = true;
break;
case SHOW_BUFFERING_NEVER:
showBufferingSpinner = false;
break;
case SHOW_BUFFERING_WHEN_PLAYING:
showBufferingSpinner = player.getPlayWhenReady();
break;
}
}
bufferingView.setVisibility(showBufferingSpinner ? View.VISIBLE : View.GONE); bufferingView.setVisibility(showBufferingSpinner ? View.VISIBLE : View.GONE);
} }
} }