diff --git a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index f22196f9fd..d1224a7dfb 100644 --- a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -562,8 +562,14 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi } private void showControls() { - mediaController.show(0); debugRootView.setVisibility(View.VISIBLE); + // TODO: Remove this hack when transitioning to our own playback controls. + mainHandler.post(new Runnable() { + @Override + public void run() { + mediaController.show(0); + } + }); } private void showToast(int messageId) { diff --git a/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaPeriod.java b/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaPeriod.java index 5d7bf1e7ea..4df6cdfebf 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaPeriod.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaPeriod.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.IdentityHashMap; /** - * Merges multiple {@link MediaPeriod} instances. + * Merges multiple {@link MediaPeriod}s. */ /* package */ final class MergingMediaPeriod implements MediaPeriod, MediaPeriod.Callback { diff --git a/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java index d6c976944f..b213928516 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java @@ -20,45 +20,79 @@ import com.google.android.exoplayer2.source.MediaPeriod.Callback; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.util.Assertions; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; /** - * Merges multiple {@link MediaPeriod} instances. + * Merges multiple {@link MediaSource}s. *
- * The {@link MediaSource}s being merged must have final windows and an equal number of periods.
+ * The {@link Timeline}s of the sources being merged must have the same number of periods, and must
+ * not have any dynamic windows.
*/
public final class MergingMediaSource implements MediaSource {
+ /**
+ * Thrown when a {@link MergingMediaSource} cannot merge its sources.
+ */
+ public static final class IllegalMergeException extends IOException {
+
+ /**
+ * The merge failed because one of the sources being merged has a dynamic window.
+ */
+ public static final int REASON_WINDOWS_ARE_DYNAMIC = 0;
+
+ /**
+ * The merge failed because the sources have different period counts.
+ */
+ public static final int REASON_PERIOD_COUNT_MISMATCH = 1;
+
+ /**
+ * The reason the merge failed. One of {@link #REASON_WINDOWS_ARE_DYNAMIC} and
+ * {@link #REASON_PERIOD_COUNT_MISMATCH}.
+ */
+ public final int reason;
+
+ /**
+ * @param reason The reason the merge failed. One of {@link #REASON_WINDOWS_ARE_DYNAMIC} and
+ * {@link #REASON_PERIOD_COUNT_MISMATCH}.
+ */
+ public IllegalMergeException(int reason) {
+ this.reason = reason;
+ }
+
+ }
+
private static final int PERIOD_COUNT_UNSET = -1;
private final MediaSource[] mediaSources;
+ private final ArrayList