🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@capgo/native-audio

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capgo/native-audio - npm Package Compare versions

Comparing version
8.3.16
to
8.3.17
+9
-3
ios/Sources/NativeAudioPlugin/AudioAsset.swift

@@ -264,6 +264,6 @@ @preconcurrency import AVFoundation

if player.volume > 0 {
fadeOut(audio: player, fadeOutDuration: fadeOutDuration, toPause: true) { [weak self] elapsed, duration in
fadeOut(audio: player, fadeOutDuration: fadeOutDuration, toPause: true, beforePause: { [weak self] elapsed, duration in
guard let self, let owner = self.owner else { return }
owner.recordPausePositionAfterFade(assetId: self.assetId, elapsedTime: elapsed, duration: duration)
}
})
} else {

@@ -277,5 +277,11 @@ cancelFade()

} else if player.volume > 0 {
fadeOut(audio: player, fadeOutDuration: fadeOutDuration, toPause: false)
fadeOut(audio: player, fadeOutDuration: fadeOutDuration, toPause: false, beforeStop: { [weak self] elapsed, duration in
guard let self, let owner = self.owner else { return }
owner.recordStoppedPlaybackStateAfterFade(assetId: self.assetId, elapsedTime: elapsed, duration: duration)
})
} else {
let elapsed = player.currentTime
let duration = player.duration.isFinite ? player.duration : 0
stop()
owner?.recordStoppedPlaybackStateAfterFade(assetId: assetId, elapsedTime: elapsed, duration: duration)
}

@@ -282,0 +288,0 @@ } else if !toPause {

@@ -37,10 +37,13 @@ import AVFoundation

fileprivate func scheduleLocalFadeOutStopOnMain(audio: AVAudioPlayer) {
fileprivate func scheduleLocalFadeOutStopOnMain(audio: AVAudioPlayer, beforeStop: ((TimeInterval, TimeInterval) -> Void)?) {
DispatchQueue.main.async { [weak self] in
guard let self else { return }
self.performLocalFadeOutStopOnMain(audio: audio)
self.performLocalFadeOutStopOnMain(audio: audio, beforeStop: beforeStop)
}
}
fileprivate func performLocalFadeOutStopOnMain(audio: AVAudioPlayer) {
fileprivate func performLocalFadeOutStopOnMain(audio: AVAudioPlayer, beforeStop: ((TimeInterval, TimeInterval) -> Void)?) {
let elapsed = audio.currentTime
let duration = audio.duration.isFinite ? audio.duration : 0
beforeStop?(elapsed, duration)
audio.stop()

@@ -75,4 +78,7 @@ dispatchComplete()

/// - Parameter beforeStop: Called on the main queue immediately before `stop()` when `toPause` is false,
/// so the plugin can refresh Now Playing (rate 0) at the final elapsed time.
/// - Parameter beforePause: Called on the main queue immediately before `pause()` when `toPause` is true,
/// so the plugin can persist `timeBeforePause` and update Now Playing at the actual stop position.
/// Kept last so call sites can use a trailing closure for fade-out-to-pause.
func fadeOut(

@@ -82,2 +88,3 @@ audio: AVAudioPlayer,

toPause: Bool = false,
beforeStop: ((TimeInterval, TimeInterval) -> Void)? = nil,
beforePause: ((TimeInterval, TimeInterval) -> Void)? = nil

@@ -91,3 +98,3 @@ ) {

} else {
scheduleLocalFadeOutStopOnMain(audio: audio)
scheduleLocalFadeOutStopOnMain(audio: audio, beforeStop: beforeStop)
}

@@ -115,3 +122,3 @@ return

} else {
self.performLocalFadeOutStopOnMain(audio: audio)
self.performLocalFadeOutStopOnMain(audio: audio, beforeStop: beforeStop)
}

@@ -118,0 +125,0 @@ }

{
"name": "@capgo/native-audio",
"version": "8.3.16",
"version": "8.3.17",
"description": "A native plugin for native audio engine",

@@ -5,0 +5,0 @@ "license": "MPL-2.0",

Sorry, the diff of this file is too big to display