Skip to content

Commit

Permalink
Cleanup recent merged pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ojw28 committed Aug 16, 2018
1 parent 071155d commit 32bd69d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 63 deletions.
10 changes: 7 additions & 3 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
on ExoPlayer via its source code rather than an AAR may need to add
`compileOptions { targetCompatibility JavaVersion.VERSION_1_8 }` to their
gradle settings to ensure bytecode compatibility.
* Add support for lazy preparation of playlist media sources in
`ConcatenatingMediaSource`
([#3972](https://github.com/google/ExoPlayer/issues/3972)).
* ConcatenatingMediaSource:
* Add support for lazy preparation of playlist media sources
([#3972](https://github.com/google/ExoPlayer/issues/3972)).
* Add support for range removal with `removeMediaSourceRange` methods.
* `BandwidthMeter` management:
* Pass `BandwidthMeter` directly to `ExoPlayerFactory` instead of
`TrackSelection.Factory` and `DataSource.Factory`. May also be omitted to
Expand Down Expand Up @@ -108,6 +109,9 @@
* IMA: Improve handling of consecutive empty ad groups
([#4030](https://github.com/google/ExoPlayer/issues/4030)),
([#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 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ public final synchronized void addMediaSources(
* <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int,
* int)} instead.
*
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use
* {@link #removeMediaSourceRange(int, int)} instead.
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use {@link
* #removeMediaSourceRange(int, int)} instead.
*
* @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()}.
Expand All @@ -281,8 +281,8 @@ public final synchronized void removeMediaSource(int index) {
* <p>Note: If you want to move the instance, it's preferable to use {@link #moveMediaSource(int,
* int, Runnable)} instead.
*
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use
* {@link #removeMediaSourceRange(int, int, Runnable)} instead.
* <p>Note: If you want to remove a set of contiguous sources, it's preferable to use {@link
* #removeMediaSourceRange(int, int, Runnable)} instead.
*
* @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()}.
Expand All @@ -307,15 +307,15 @@ public final synchronized void removeMediaSource(
* Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index
* (included) and a final index (excluded).
*
* <p>Note: when specified range is empty, no actual media source is removed and no exception
* is thrown.
* <p>Note: when specified range is empty, no actual media source is removed and no exception is
* thrown.
*
* @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()}.
* @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()}.
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt;
* 0, {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; 0,
* {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
*/
public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex) {
removeMediaSourceRange(fromIndex, toIndex, null);
Expand All @@ -325,20 +325,20 @@ public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex
* 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.
*
* <p>Note: when specified range is empty, no actual media source is removed and no exception
* is thrown.
* <p>Note: when specified range is empty, no actual media source is removed and no exception is
* thrown.
*
* @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()}.
* @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()}.
* @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
* source range has been removed from the playlist.
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt;
* 0, {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} &lt; 0,
* {@code toIndex} &gt; {@link #getSize()}, {@code fromIndex} &gt; {@code toIndex}
*/
public final synchronized void removeMediaSourceRange(
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) {
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) {
Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
if (fromIndex == toIndex) {
if (actionOnCompletion != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

/**
* 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
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.support.annotation.IntDef;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
Expand Down Expand Up @@ -89,7 +89,7 @@
* <li><b>{@code default_artwork}</b> - Default artwork to use if no artwork available in audio
* streams.
* <ul>
* <li>Corresponding method: {@link #setDefaultArtwork(Bitmap)}
* <li>Corresponding method: {@link #setDefaultArtwork(Drawable)}
* <li>Default: {@code null}
* </ul>
* <li><b>{@code use_controller}</b> - Whether the playback controls can be shown.
Expand All @@ -116,10 +116,10 @@
* <li>Default: {@code true}
* </ul>
* <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>
* <li>Corresponding method: {@link #setShowBuffering(boolean)}
* <li>Default: {@code false}
* <li>Corresponding method: {@link #setShowBuffering(int)}
* <li>Default: {@code never}
* </ul>
* <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}.
Expand Down Expand Up @@ -243,13 +243,22 @@ public class PlayerView extends FrameLayout {
private static final int SURFACE_TYPE_TEXTURE_VIEW = 2;
private static final int SURFACE_TYPE_MONO360_VIEW = 3;

public static final int SHOW_BUFFERING_NEVER = 0;
public static final int SHOW_BUFFERING_ALWAYS = 1;
public static final int SHOW_BUFFERING_WHEN_PLAYING = 2;

/** Determines when the buffering view is shown. */
@IntDef({SHOW_BUFFERING_NEVER, SHOW_BUFFERING_WHEN_PLAYING, SHOW_BUFFERING_ALWAYS})
@Retention(RetentionPolicy.SOURCE)
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 View shutterView;
Expand All @@ -265,7 +274,7 @@ public class PlayerView extends FrameLayout {
private Player player;
private boolean useController;
private boolean useArtwork;
private Drawable defaultArtwork;
private @Nullable Drawable defaultArtwork;
private @ShowBuffering int showBuffering;
private boolean keepContentOnPlayerReset;
private @Nullable ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
Expand Down Expand Up @@ -598,8 +607,9 @@ public Drawable getDefaultArtwork() {
* @deprecated use (@link {@link #setDefaultArtwork(Drawable)} instead.
*/
@Deprecated
public void setDefaultArtwork(Bitmap defaultArtwork) {
setDefaultArtwork(new BitmapDrawable(getResources(), defaultArtwork));
public void setDefaultArtwork(@Nullable Bitmap defaultArtwork) {
setDefaultArtwork(
defaultArtwork == null ? null : new BitmapDrawable(getResources(), defaultArtwork));
}

/**
Expand All @@ -608,7 +618,7 @@ public void setDefaultArtwork(Bitmap defaultArtwork) {
*
* @param defaultArtwork the default artwork to display
*/
public void setDefaultArtwork(Drawable defaultArtwork) {
public void setDefaultArtwork(@Nullable Drawable defaultArtwork) {
if (this.defaultArtwork != defaultArtwork) {
this.defaultArtwork = defaultArtwork;
updateForCurrentTrackSelections(/* isNewPlayer= */ false);
Expand Down Expand Up @@ -682,7 +692,6 @@ public void setKeepContentOnPlayerReset(boolean keepContentOnPlayerReset) {
* buffering spinner is not displayed by default.
*
* @deprecated Use {@link #setShowBuffering(int)}
*
* @param showBuffering Whether the buffering icon is displayed
*/
@Deprecated
Expand All @@ -692,15 +701,11 @@ public void setShowBuffering(boolean showBuffering) {

/**
* 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})
*
* <p><ul>
* <li>{@link #SHOW_BUFFERING_ALWAYS} displayed always when buffering
* <li>{@link #SHOW_BUFFERING_NEVER} not displayed at all
* <li>{@link #SHOW_BUFFERING_WHEN_PLAYING} displayed only when playing and buffering
* </ul></p>
* buffering spinner is not displayed by default.
*
* @param showBuffering Buffering strategy that defines when the buffering icon is displayed
* @param showBuffering The mode that defines when the buffering spinner is displayed. One of
* {@link #SHOW_BUFFERING_NEVER}, {@link #SHOW_BUFFERING_WHEN_PLAYING} and
* {@link #SHOW_BUFFERING_ALWAYS}.
*/
public void setShowBuffering(@ShowBuffering int showBuffering) {
if (this.showBuffering != showBuffering) {
Expand Down Expand Up @@ -1153,14 +1158,20 @@ private boolean setArtworkFromMetadata(Metadata metadata) {
return false;
}

private boolean setDrawableArtwork(Drawable drawable) {
if(drawable != null) {
artworkView.setImageDrawable(drawable);
if(contentFrame != null) {
contentFrame.setAspectRatio(0);
private boolean setDrawableArtwork(@Nullable Drawable drawable) {
if (drawable != null) {
int drawableWidth = drawable.getIntrinsicWidth();
int drawableHeight = drawable.getIntrinsicHeight();
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() {
Expand All @@ -1178,23 +1189,11 @@ private void closeShutter() {

private void updateBuffering() {
if (bufferingView != null) {

boolean showBufferingSpinner = false;

if (player != null && player.getPlaybackState() == Player.STATE_BUFFERING) {
switch (showBuffering) {
case SHOW_BUFFERING_ALWAYS:
showBufferingSpinner = true;
break;
case SHOW_BUFFERING_NEVER:
showBufferingSpinner = false;
break;
case SHOW_BUFFERING_WHEN_PLAYING:
showBufferingSpinner = player.getPlayWhenReady();
break;
}
}

boolean showBufferingSpinner =
player != null
&& player.getPlaybackState() == Player.STATE_BUFFERING
&& (showBuffering == SHOW_BUFFERING_ALWAYS
|| (showBuffering == SHOW_BUFFERING_WHEN_PLAYING && player.getPlayWhenReady()));
bufferingView.setVisibility(showBufferingSpinner ? View.VISIBLE : View.GONE);
}
}
Expand Down

0 comments on commit 32bd69d

Please sign in to comment.