AudioPlayerManager
AudioPlayerManager copied to clipboard
loadDuration in AVAsset+Metadata returns nil in xcode 11 ios 13
Hello! Wie geht es dit? this is a really awesome repo by the way!
I have noticed a problem when trying my app that uses your repo which is that the seek bar is not shown in control center. Please note that i am not sure if the problem is only in my use case or the loadDuration func is bugged. The problem was in the function "updateNowPlayingInfoPlaybackDuration" of AudioTrack.swift it returned nil duration and i was able to solve it by changing it to
open func updateNowPlayingInfoPlaybackDuration() {
self.playerItem?.asset.loadDuration(completion: { [weak self] (duration: NSNumber?) in
if duration != nil {
self?.nowPlayingInfo?[MPMediaItemPropertyPlaybackDuration] = duration
} else {
if let durationShit = self?.playerItem?.asset.duration, durationShit != CMTime.indefinite {
self?.nowPlayingInfo?[MPMediaItemPropertyPlaybackDuration] = NSNumber(value: CMTimeGetSeconds(durationShit))
print("did set duration = \(NSNumber(value: CMTimeGetSeconds(durationShit)))")
}
}
})
}
Have a nice day.