I tried playing a .wav
of 7 minutes,17 minutes, 20 minutes works fine, but when trying to play an audio of 1.04 hour it doesn't work.
And I am sure that .wav file I am using is not corrupted since its being used by android app and they are able to get the duration.
While playing 1.04 hour audio it results .failed
, in below code
if let url = URL(string: urlString) {
audioAsset = AVURLAsset.init(url: url)
if let audioAsset = audioAsset {
let keys = ["playable"]
audioAsset.loadValuesAsynchronously(forKeys: keys, completionHandler: {
let playableStatus = audioAsset.statusOfValue(forKey: keys[0], error: nil)
switch playableStatus {
case .unknown, .loading, .failed, .cancelled:
return
case .loaded:
DispatchQueue.main.async {
let playerItem = AVPlayerItem.init(asset: audioAsset)
self.audioPlayer.insert(playerItem, after: nil)
self.audioPlayer.play()
})
}
break
}
})
}
}
I tried playing audio 1 Hour without AVURLAsset
as below code Audio was not playing.
let playerItem = AVPlayerItem.init(url: url)
self.audioPlayer.insert(playerItem, after: nil)
self.audioPlayer.play()
It would be very helpful if I get solution for my problem. or possible reason why this happens ?