mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Assign error codes to FileDataSourceExceptions
PiperOrigin-RevId: 377481210
This commit is contained in:
parent
536f7c8dbe
commit
29eeff9ff7
2 changed files with 13 additions and 2 deletions
|
|
@ -46,6 +46,7 @@ import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
|||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
|
||||
import com.google.android.exoplayer2.upstream.BandwidthMeter;
|
||||
import com.google.android.exoplayer2.upstream.FileDataSource;
|
||||
import com.google.android.exoplayer2.upstream.HttpDataSource;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Clock;
|
||||
|
|
@ -55,6 +56,7 @@ import com.google.android.exoplayer2.util.TraceUtil;
|
|||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -572,6 +574,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false);
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(e);
|
||||
}
|
||||
} catch (FileDataSource.FileDataSourceException e) {
|
||||
@Nullable Throwable cause = e.getCause();
|
||||
int errorCode = PlaybackException.ERROR_CODE_IO_UNSPECIFIED;
|
||||
if (cause instanceof FileNotFoundException) {
|
||||
errorCode = PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND;
|
||||
} else if (cause instanceof SecurityException) {
|
||||
errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION;
|
||||
}
|
||||
handleIoException(e, errorCode);
|
||||
} catch (ParserException e) {
|
||||
int errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED;
|
||||
if (e.dataType == C.DATA_TYPE_MEDIA) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public final class FileDataSource extends BaseDataSource {
|
|||
/** Thrown when a {@link FileDataSource} encounters an error reading a file. */
|
||||
public static class FileDataSourceException extends IOException {
|
||||
|
||||
public FileDataSourceException(IOException cause) {
|
||||
public FileDataSourceException(Exception cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public final class FileDataSource extends BaseDataSource {
|
|||
}
|
||||
} catch (FileDataSourceException e) {
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
throw new FileDataSourceException(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue