悪い URL を含む AudioSources のプレイリストを取得しました (情報とともに 400 エラーを返します)。そして、ConcatenatingAudioSource を使用してこれらのオーディオをラップし、setAudioSource に渡します。
プレーヤーがその悪い URL オーディオ ソースを再生すると、次のようなものがスローされます。
E/ExoPlayerImplInternal(10255): Playback error
E/ExoPlayerImplInternal(10255): com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:624)
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:596)
E/ExoPlayerImplInternal(10255): at android.os.Handler.dispatchMessage(Handler.java:103)
E/ExoPlayerImplInternal(10255): at android.os.Looper.loop(Looper.java:214)
E/ExoPlayerImplInternal(10255): at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(10255): Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 400
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:389)
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1014)
E/ExoPlayerImplInternal(10255): at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:409)
E/ExoPlayerImplInternal(10255): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(10255): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(10255): at java.lang.Thread.run(Thread.java:919)
E/AudioPlayer(10255): TYPE_SOURCE: Response code: 400
この状況でエラーをキャッチするにはどうすればよいですか?
これまでにキャッチしようとしたもの:
audioPlayer.playbackEventStream.listen(
(event) {},
onError: (Object e, StackTrace stackTrace) {
print('A stream error occurred: $e');
},
);
audioPlayer.sequenceStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A sequence error occurred: $e');
});
audioPlayer.sequenceStateStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A sequencestate error occurred: $e');
});
audioPlayer.processingStateStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A processingState error occurred: $e');
});
audioPlayer.playerStateStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A playerStateStream error occurred: $e');
});
audioPlayer.playingStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A playingStream error occurred: $e');
});
audioPlayer.bufferedPositionStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A bufferedPositionStream error occurred: $e');
});
try {
await audioPlayer
.setAudioSource(_playlist, preload: true)
.onError((e, stackTrace) {
print('A player error occurred: $e');
});
} catch (e) {
print("Error loading playlist occurred: $e");
}