Reputation: 2072
I'm using SwiftyDropbox
's getTemporaryLink()
to play a video in an AVPlayer
. I have six test files, and they all work as expected, except 1.
The one that doesn't work is 41 MB in size (which I would not consider a large video file), the rest are < 22 MB.
I've read the AVFoundation
and SwiftDropbox
documentation many times and haven't been able to find anything on a maximum file size, though I wouldn't expect a maximum file size for streaming content. I would expect it to continuously play smaller chunks downloaded to memory.
My questions are:
AVPlayer
?AVPlayer
in order to stream these larger files?I'm using the following code to start the AVPlayer
:
self.previewPlayer.replaceCurrentItem(with: AVPlayerItem(url: URL(fileURLWithPath: url)))
self.previewPlayer.play()
Thank-you!
Upvotes: 0
Views: 1443
Reputation: 2496
You should observe the value of status
property to know why the playerItem might have failed to play. Here's a small code snippet to start with:
Add observer
let url = URL.init(string: "your url string")
let item = AVPlayerItem.init(url: url!)
item.addObserver(self,
forKeyPath: "status",
options: .new,
context: nil)
Check for the the error
override func observeValue(forKeyPath keyPath: String?,
of object: Any?,
change: [NSKeyValueChangeKey : Any]?,
context: UnsafeMutableRawPointer?) {
if let item = object as? AVPlayerItem, keyPath == "status" {
if item.status == .failed {
print(item.error?.localizedDescription ?? "Unknown error")
}
}
}
Upvotes: 0