Ensure native platform is disposed.

This commit is contained in:
Ryan Heise 2020-12-23 19:26:59 +11:00
parent 2aa9342442
commit 86a880a08a
1 changed files with 3 additions and 1 deletions

View File

@ -918,7 +918,8 @@ class AudioPlayer {
final currentIndex = this.currentIndex;
final audioSource = _audioSource;
final newPlatform = active
? JustAudioPlatform.instance.init(InitRequest(id: _id))
? (_nativePlatform =
JustAudioPlatform.instance.init(InitRequest(id: _id)))
: Future.value(_idlePlatform);
_playbackEventSubscription?.cancel();
final durationCompleter = Completer<Duration>();
@ -1031,6 +1032,7 @@ class AudioPlayer {
if (platform is _IdleAudioPlayer) {
await platform.dispose(DisposeRequest());
} else {
_nativePlatform = null;
try {
await JustAudioPlatform.instance
.disposePlayer(DisposePlayerRequest(id: _id));