mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Propagate MediaSource loading errors to the player.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127551577
This commit is contained in:
parent
98a0c5f05c
commit
ff914afd7f
4 changed files with 13 additions and 6 deletions
|
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 @@
|
||||||
*/
|
*/
|
||||||
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 {
|
||||||
*/
|
*/
|
||||||
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 {
|
||||||
* 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;
|
||||||
|
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue