mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
Make SingleSampleMediaSource.Factory reusable
PiperOrigin-RevId: 292879934
This commit is contained in:
parent
b6bd57ab12
commit
c095a9ff98
@ -59,7 +59,6 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
|
|
||||||
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private boolean treatLoadErrorsAsEndOfStream;
|
private boolean treatLoadErrorsAsEndOfStream;
|
||||||
private boolean isCreateCalled;
|
|
||||||
@Nullable private Object tag;
|
@Nullable private Object tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,8 +80,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setTag(Object tag) {
|
public Factory setTag(@Nullable Object tag) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -115,9 +113,12 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
public Factory setLoadErrorHandlingPolicy(
|
||||||
Assertions.checkState(!isCreateCalled);
|
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
||||||
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
this.loadErrorHandlingPolicy =
|
||||||
|
loadErrorHandlingPolicy != null
|
||||||
|
? loadErrorHandlingPolicy
|
||||||
|
: new DefaultLoadErrorHandlingPolicy();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,6 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setTreatLoadErrorsAsEndOfStream(boolean treatLoadErrorsAsEndOfStream) {
|
public Factory setTreatLoadErrorsAsEndOfStream(boolean treatLoadErrorsAsEndOfStream) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
|
||||||
this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
|
this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,6 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
* @return The new {@link SingleSampleMediaSource}.
|
* @return The new {@link SingleSampleMediaSource}.
|
||||||
*/
|
*/
|
||||||
public SingleSampleMediaSource createMediaSource(Uri uri, Format format, long durationUs) {
|
public SingleSampleMediaSource createMediaSource(Uri uri, Format format, long durationUs) {
|
||||||
isCreateCalled = true;
|
|
||||||
return new SingleSampleMediaSource(
|
return new SingleSampleMediaSource(
|
||||||
uri,
|
uri,
|
||||||
dataSourceFactory,
|
dataSourceFactory,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user