Commit ff914afd by eguven Committed by Oliver Woodman

Propagate MediaSource loading errors to the player.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127551577
parent 98a0c5f0
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.source; package com.google.android.exoplayer2.source;
import java.io.IOException;
/** /**
* Concatenates multiple {@link MediaSource}s. * Concatenates multiple {@link MediaSource}s.
*/ */
...@@ -50,7 +52,7 @@ public final class ConcatenatingMediaSource implements MediaSource { ...@@ -50,7 +52,7 @@ public final class ConcatenatingMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index) { public MediaPeriod createPeriod(int index) throws IOException {
int sourceCount = 0; int sourceCount = 0;
for (MediaSource mediaSource : mediaSources) { for (MediaSource mediaSource : mediaSources) {
int count = mediaSource.getPeriodCount(); int count = mediaSource.getPeriodCount();
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.source; package com.google.android.exoplayer2.source;
import java.io.IOException;
/** /**
* A source of media consisting of one or more {@link MediaPeriod}s. * A source of media consisting of one or more {@link MediaPeriod}s.
*/ */
...@@ -30,8 +32,6 @@ public interface MediaSource { ...@@ -30,8 +32,6 @@ public interface MediaSource {
*/ */
void prepareSource(); void prepareSource();
// TODO add void maybeThrowError() throws IOException;
/** /**
* Returns the number of periods in the source, or {@link #UNKNOWN_PERIOD_COUNT} if the number * Returns the number of periods in the source, or {@link #UNKNOWN_PERIOD_COUNT} if the number
* of periods is not yet known. * of periods is not yet known.
...@@ -46,8 +46,10 @@ public interface MediaSource { ...@@ -46,8 +46,10 @@ public interface MediaSource {
* period count is {@link #UNKNOWN_PERIOD_COUNT}. * period count is {@link #UNKNOWN_PERIOD_COUNT}.
* @return A {@link MediaPeriod}, or {@code null} if the source at the specified index is not yet * @return A {@link MediaPeriod}, or {@code null} if the source at the specified index is not yet
* available. * available.
* @throws IOException If there is an error that's preventing the source from becoming prepared or
* creating periods.
*/ */
MediaPeriod createPeriod(int index); MediaPeriod createPeriod(int index) throws IOException;
/** /**
* Releases the source. * Releases the source.
......
...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source; ...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException;
/** /**
* Merges multiple {@link MediaPeriod} instances. * Merges multiple {@link MediaPeriod} instances.
* <p> * <p>
...@@ -55,7 +57,7 @@ public final class MergingMediaSource implements MediaSource { ...@@ -55,7 +57,7 @@ public final class MergingMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index) { public MediaPeriod createPeriod(int index) throws IOException {
MediaPeriod[] periods = new MediaPeriod[mediaSources.length]; MediaPeriod[] periods = new MediaPeriod[mediaSources.length];
for (int i = 0; i < periods.length; i++) { for (int i = 0; i < periods.length; i++) {
periods[i] = mediaSources[i].createPeriod(index); periods[i] = mediaSources[i].createPeriod(index);
......
...@@ -113,8 +113,9 @@ public final class DashMediaSource implements MediaSource { ...@@ -113,8 +113,9 @@ public final class DashMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index) { public MediaPeriod createPeriod(int index) throws IOException {
if (periods == null) { if (periods == null) {
loader.maybeThrowError();
return null; return null;
} }
return periods[index]; return periods[index];
......
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