I'm trying to play a video downloaded to the device's document directory. For some reason, it won't happen. All I get is this symbol:
Here's my code:
let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
let videoFileUrl = URL(fileUrlWithPath: documentPath)
let videoFilePath = videoFileUrl.appendingPathComponent("somVideo.mp4").path
if FileManager.default.fileExists(atPath: videFilePath){
let player = AVPlayer(url: URL(string: videoFilePath)!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
}
else {
print("File doesn't exist")
}
The file exists at the location - I have checked my documents directory for the simulator - and the else
statement isn't fired. Nothing else is printed to the console.
Any help would be appreciated.