@capgo/native-audio
Advanced tools
@@ -15,3 +15,3 @@ import AVFoundation | ||
| public class NativeAudio: CAPPlugin, AVAudioPlayerDelegate, CAPBridgedPlugin { | ||
| private let pluginVersion: String = "8.3.0" | ||
| private let pluginVersion: String = "8.3.1" | ||
| public let identifier = "NativeAudio" | ||
@@ -644,6 +644,17 @@ public let jsName = "NativeAudio" | ||
| // Don't immediately end the session here, as other players might still be active | ||
| // Instead, check if all players are done | ||
| // Instead, check if all players are done and clear Now Playing if this asset was current | ||
| audioQueue.async { [weak self] in | ||
| guard let self = self else { return } | ||
| // Find which asset this player belongs to; if it was the currently playing one, clear notification | ||
| for (audioId, asset) in self.audioList { | ||
| if let audioAsset = asset as? AudioAsset, audioAsset.channels.contains(player) { | ||
| if self.currentlyPlayingAssetId == audioId { | ||
| self.currentlyPlayingAssetId = nil | ||
| self.clearNowPlayingInfo() | ||
| } | ||
| break | ||
| } | ||
| } | ||
| // Avoid recursive calls by checking if the asset is still in the list | ||
@@ -660,2 +671,7 @@ let hasPlayingAssets = self.audioList.values.contains { asset in | ||
| if !hasPlayingAssets { | ||
| // If we didn't find the asset above (e.g. playOnce already removed it), clear notification when nothing is playing | ||
| if self.currentlyPlayingAssetId != nil { | ||
| self.currentlyPlayingAssetId = nil | ||
| self.clearNowPlayingInfo() | ||
| } | ||
| self.endSession() | ||
@@ -662,0 +678,0 @@ } |
+1
-1
| { | ||
| "name": "@capgo/native-audio", | ||
| "version": "8.3.0", | ||
| "version": "8.3.1", | ||
| "description": "A native plugin for native audio engine", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
668612
0.13%