Propagate MediaSource loading errors to the player.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127551577
This commit is contained in:
eguven 2016-07-15 10:12:57 -07:00 committed by Oliver Woodman
parent 98a0c5f05c
commit ff914afd7f
4 changed files with 13 additions and 6 deletions

View file

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.source;
import java.io.IOException;
/**
* Concatenates multiple {@link MediaSource}s.
*/
@ -50,7 +52,7 @@ public final class ConcatenatingMediaSource implements MediaSource {
}
@Override
public MediaPeriod createPeriod(int index) {
public MediaPeriod createPeriod(int index) throws IOException {
int sourceCount = 0;
for (MediaSource mediaSource : mediaSources) {
int count = mediaSource.getPeriodCount();

View file

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.source;
import java.io.IOException;
/**
* A source of media consisting of one or more {@link MediaPeriod}s.
*/
@ -30,8 +32,6 @@ public interface MediaSource {
*/
void prepareSource();
// TODO add void maybeThrowError() throws IOException;
/**
* Returns the number of periods in the source, or {@link #UNKNOWN_PERIOD_COUNT} if the number
* of periods is not yet known.
@ -46,8 +46,10 @@ public interface MediaSource {
* period count is {@link #UNKNOWN_PERIOD_COUNT}.
* @return A {@link MediaPeriod}, or {@code null} if the source at the specified index is not yet
* 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.

View file

@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException;
/**
* Merges multiple {@link MediaPeriod} instances.
* <p>
@ -55,7 +57,7 @@ public final class MergingMediaSource implements MediaSource {
}
@Override
public MediaPeriod createPeriod(int index) {
public MediaPeriod createPeriod(int index) throws IOException {
MediaPeriod[] periods = new MediaPeriod[mediaSources.length];
for (int i = 0; i < periods.length; i++) {
periods[i] = mediaSources[i].createPeriod(index);

View file

@ -113,8 +113,9 @@ public final class DashMediaSource implements MediaSource {
}
@Override
public MediaPeriod createPeriod(int index) {
public MediaPeriod createPeriod(int index) throws IOException {
if (periods == null) {
loader.maybeThrowError();
return null;
}
return periods[index];