Commit 9778898b by Oliver Woodman

Merge branch 'dev-v2' into dev-v2-r2.12.0

parents db63334f e1c3da2a
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
([#6161](https://github.com/google/ExoPlayer/issues/6161)). The ([#6161](https://github.com/google/ExoPlayer/issues/6161)). The
new methods for playlist manipulation are `setMediaItem(s)`, new methods for playlist manipulation are `setMediaItem(s)`,
`addMediaItem(s)`, `moveMediaItem(s)`, `removeMediaItem(s)` and `addMediaItem(s)`, `moveMediaItem(s)`, `removeMediaItem(s)` and
`clearMediaItems`. `clearMediaItems`. This API should be used instead of
`ConcatenatingMediaSource` in most cases.
* Add `getCurrentMediaItem` for getting the currently playing item * Add `getCurrentMediaItem` for getting the currently playing item
in the playlist. in the playlist.
* Add `EventListener.onMediaItemTransition` to report when * Add `EventListener.onMediaItemTransition` to report when
......
...@@ -163,6 +163,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -163,6 +163,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private final BandwidthMeter bandwidthMeter; private final BandwidthMeter bandwidthMeter;
private final HandlerWrapper handler; private final HandlerWrapper handler;
private final HandlerThread internalPlaybackThread; private final HandlerThread internalPlaybackThread;
private final Looper playbackLooper;
private final Timeline.Window window; private final Timeline.Window window;
private final Timeline.Period period; private final Timeline.Period period;
private final long backBufferDurationUs; private final long backBufferDurationUs;
...@@ -252,7 +253,8 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -252,7 +253,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
// not normally change to this priority" is incorrect. // not normally change to this priority" is incorrect.
internalPlaybackThread = new HandlerThread("ExoPlayer:Playback", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread = new HandlerThread("ExoPlayer:Playback", Process.THREAD_PRIORITY_AUDIO);
internalPlaybackThread.start(); internalPlaybackThread.start();
handler = clock.createHandler(internalPlaybackThread.getLooper(), this); playbackLooper = internalPlaybackThread.getLooper();
handler = clock.createHandler(playbackLooper, this);
} }
public void experimentalSetReleaseTimeoutMs(long releaseTimeoutMs) { public void experimentalSetReleaseTimeoutMs(long releaseTimeoutMs) {
...@@ -403,7 +405,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -403,7 +405,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
public Looper getPlaybackLooper() { public Looper getPlaybackLooper() {
return internalPlaybackThread.getLooper(); return playbackLooper;
} }
// Playlist.PlaylistInfoRefreshListener implementation. // Playlist.PlaylistInfoRefreshListener implementation.
...@@ -1365,7 +1367,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1365,7 +1367,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
private void sendMessageToTarget(PlayerMessage message) throws ExoPlaybackException { private void sendMessageToTarget(PlayerMessage message) throws ExoPlaybackException {
if (message.getHandler().getLooper() == handler.getLooper()) { if (message.getHandler().getLooper() == playbackLooper) {
deliverMessage(message); deliverMessage(message);
if (playbackInfo.playbackState == Player.STATE_READY if (playbackInfo.playbackState == Player.STATE_READY
|| playbackInfo.playbackState == Player.STATE_BUFFERING) { || playbackInfo.playbackState == Player.STATE_BUFFERING) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Constructor method accessed via reflection in TrackSelectionDialogBuilder # Constructor method accessed via reflection in TrackSelectionDialogBuilder
-dontnote androidx.appcompat.app.AlertDialog.Builder -dontnote androidx.appcompat.app.AlertDialog.Builder
-keepclassmembers class androidx.appcompat.app.AlertDialog$Builder { -keepclassmembers class androidx.appcompat.app.AlertDialog$Builder {
<init>(android.content.Context); <init>(android.content.Context, int);
public android.content.Context getContext(); public android.content.Context getContext();
public androidx.appcompat.app.AlertDialog$Builder setTitle(java.lang.CharSequence); public androidx.appcompat.app.AlertDialog$Builder setTitle(java.lang.CharSequence);
public androidx.appcompat.app.AlertDialog$Builder setView(android.view.View); public androidx.appcompat.app.AlertDialog$Builder setView(android.view.View);
......
...@@ -24,6 +24,7 @@ import android.content.DialogInterface; ...@@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride;
...@@ -49,6 +50,7 @@ public final class TrackSelectionDialogBuilder { ...@@ -49,6 +50,7 @@ public final class TrackSelectionDialogBuilder {
} }
private final Context context; private final Context context;
@StyleRes private int themeResId;
private final CharSequence title; private final CharSequence title;
private final MappedTrackInfo mappedTrackInfo; private final MappedTrackInfo mappedTrackInfo;
private final int rendererIndex; private final int rendererIndex;
...@@ -122,6 +124,17 @@ public final class TrackSelectionDialogBuilder { ...@@ -122,6 +124,17 @@ public final class TrackSelectionDialogBuilder {
} }
/** /**
* Sets the resource ID of the theme used to inflate this dialog.
*
* @param themeResId The resource ID of the theme.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setTheme(@StyleRes int themeResId) {
this.themeResId = themeResId;
return this;
}
/**
* Sets whether the selection is initially shown as disabled. * Sets whether the selection is initially shown as disabled.
* *
* @param isDisabled Whether the selection is initially shown as disabled. * @param isDisabled Whether the selection is initially shown as disabled.
...@@ -214,7 +227,7 @@ public final class TrackSelectionDialogBuilder { ...@@ -214,7 +227,7 @@ public final class TrackSelectionDialogBuilder {
} }
private Dialog buildForPlatform() { private Dialog buildForPlatform() {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context, themeResId);
// Inflate with the builder's context to ensure the correct style is used. // Inflate with the builder's context to ensure the correct style is used.
LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext()); LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
...@@ -238,8 +251,8 @@ public final class TrackSelectionDialogBuilder { ...@@ -238,8 +251,8 @@ public final class TrackSelectionDialogBuilder {
// the APK size even with shrinking. See https://issuetracker.google.com/161514204. // the APK size even with shrinking. See https://issuetracker.google.com/161514204.
// LINT.IfChange // LINT.IfChange
Class<?> builderClazz = Class.forName("androidx.appcompat.app.AlertDialog$Builder"); Class<?> builderClazz = Class.forName("androidx.appcompat.app.AlertDialog$Builder");
Constructor<?> builderConstructor = builderClazz.getConstructor(Context.class); Constructor<?> builderConstructor = builderClazz.getConstructor(Context.class, int.class);
Object builder = builderConstructor.newInstance(context); Object builder = builderConstructor.newInstance(context, themeResId);
// Inflate with the builder's context to ensure the correct style is used. // Inflate with the builder's context to ensure the correct style is used.
Context builderContext = (Context) builderClazz.getMethod("getContext").invoke(builder); Context builderContext = (Context) builderClazz.getMethod("getContext").invoke(builder);
......
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