Only open the video player if the file is a video
This commit is contained in:
parent
9862d3816b
commit
45bbbf8945
1 changed files with 11 additions and 12 deletions
|
@ -68,18 +68,17 @@ class PostViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func playAction(_ sender: Any) {
|
@IBAction func playAction(_ sender: Any) {
|
||||||
let imagePath = documentsPath.appendingPathComponent(post!.value(forKey: "name") as! String).path
|
if((post?.value(forKey: "type") as? String) == "public.mpeg-4") {
|
||||||
|
let imagePath = documentsPath.appendingPathComponent(post!.value(forKey: "name") as! String).path
|
||||||
|
|
||||||
// Create an AVPlayer, passing it the HTTP Live Streaming URL.
|
let player = AVPlayer(url: URL(fileURLWithPath: imagePath))
|
||||||
let player = AVPlayer(url: URL(fileURLWithPath: imagePath))
|
|
||||||
|
|
||||||
// Create a new AVPlayerViewController and pass it a reference to the player.
|
let controller = AVPlayerViewController()
|
||||||
let controller = AVPlayerViewController()
|
controller.player = player
|
||||||
controller.player = player
|
|
||||||
|
|
||||||
// Modally present the player and call the player's play() method when complete.
|
present(controller, animated: true) {
|
||||||
present(controller, animated: true) {
|
player.play()
|
||||||
player.play()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue