Cancel event subscription before disposing platform.
This commit is contained in:
parent
2cb1c04dfe
commit
baa73045f0
|
@ -921,6 +921,7 @@ class AudioPlayer {
|
||||||
final audioSource = _audioSource;
|
final audioSource = _audioSource;
|
||||||
final durationCompleter = Completer<Duration>();
|
final durationCompleter = Completer<Duration>();
|
||||||
_platform = Future<AudioPlayerPlatform>(() async {
|
_platform = Future<AudioPlayerPlatform>(() async {
|
||||||
|
_playbackEventSubscription?.cancel();
|
||||||
if (oldPlatformFuture != null) {
|
if (oldPlatformFuture != null) {
|
||||||
final oldPlatform = await oldPlatformFuture;
|
final oldPlatform = await oldPlatformFuture;
|
||||||
if (oldPlatform != _idlePlatform) {
|
if (oldPlatform != _idlePlatform) {
|
||||||
|
@ -933,7 +934,6 @@ class AudioPlayer {
|
||||||
? await (_nativePlatform =
|
? await (_nativePlatform =
|
||||||
JustAudioPlatform.instance.init(InitRequest(id: _id)))
|
JustAudioPlatform.instance.init(InitRequest(id: _id)))
|
||||||
: _idlePlatform;
|
: _idlePlatform;
|
||||||
_playbackEventSubscription?.cancel();
|
|
||||||
_playbackEventSubscription =
|
_playbackEventSubscription =
|
||||||
platform.playbackEventMessageStream.listen((message) {
|
platform.playbackEventMessageStream.listen((message) {
|
||||||
var duration = message.duration;
|
var duration = message.duration;
|
||||||
|
|
Loading…
Reference in New Issue