Forward ExoPlaybackException exceptions to the Flutter plugin (#80)

* Forward ExoPlaybackException exceptions to playbackEventStream

* Ignore error events in secondary streams
This commit is contained in:
Andrea Jonus 2020-05-01 00:52:58 +10:00 committed by GitHub
parent 571743a11f
commit 3dfcef6ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -349,6 +349,10 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
prepareResult.error(errorCode, errorMsg, null);
prepareResult = null;
}
if (eventSink != null) {
eventSink.error(errorCode, errorMsg, null);
}
}
private void transition(final PlaybackState newState) {

View File

@ -132,15 +132,15 @@ class AudioPlayer {
isPublic: data[5][1][5])),
));
_eventChannelStreamSubscription =
_eventChannelStream.listen(_playbackEventSubject.add);
_eventChannelStream.listen(_playbackEventSubject.add, onError: _playbackEventSubject.addError);
_playbackStateSubject
.addStream(playbackEventStream.map((state) => state.state).distinct());
.addStream(playbackEventStream.map((state) => state.state).distinct().handleError((err,stack){ /* noop */ }));
_bufferingSubject.addStream(
playbackEventStream.map((state) => state.buffering).distinct());
playbackEventStream.map((state) => state.buffering).distinct().handleError((err,stack){ /* noop */ }));
_bufferedPositionSubject.addStream(
playbackEventStream.map((state) => state.bufferedPosition).distinct());
playbackEventStream.map((state) => state.bufferedPosition).distinct().handleError((err,stack){ /* noop */ }));
_icyMetadataSubject.addStream(
playbackEventStream.map((state) => state.icyMetadata).distinct());
playbackEventStream.map((state) => state.icyMetadata).distinct().handleError((err,stack){ /* noop */ }));
_fullPlaybackStateSubject.addStream(Rx.combineLatest3<AudioPlaybackState,
bool, IcyMetadata, FullAudioPlaybackState>(
playbackStateStream,