I'm trying to play an mp4 video from documents path in a AVPlayerViewController with an AVPlayer but it doesn't appear anything on screen.What am I doing wrong?
Here a screenshot of the simulator: http://postimg.org/image/xma60nfrf/
and this is my code:
func startPlayer(filePath:String)
{
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask, true)
let docsDir = dirPaths[0]
let filePath = (docsDir as NSString).stringByAppendingPathComponent(videos[videoNo]._Name)
playerVC=AVPlayerViewController()
playerVC!.view.frame=self.view.bounds
playerVC!.view.layer.zPosition = 1;
var videoURL = NSURL(string: filePath)
var player = AVPlayer(URL: videoURL!)
var playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = playerVC!.view.bounds
playerVC!.view.layer.addSublayer(playerLayer)
playerVC!.player=player
self.view.addSubview(playerVC!.view)
playerVC!.player!.play()
}