# Swift 3 video; bad instruction error

**URL:** <https://forums.kodeco.com/t/swift-3-video-bad-instruction-error/21821>\
**Category:** Swift\
**Created:** [October 27, 2016, 4:08pm UTC](https://forums.kodeco.com/t/swift-3-video-bad-instruction-error/21821 "2016-10-27T16:08:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zalubski](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/zalubski/32/81494_2.png) [@zalubski](https://forums.kodeco.com/u/zalubski)\
**Post date:** [October 27, 2016, 4:08pm UTC](https://forums.kodeco.com/t/swift-3-video-bad-instruction-error/21821/1 "2016-10-27T16:08:32Z")

</div>

All I am trying to do is have a view Controller that has button. When pressed it will play a video.

My code has a runtime bad instruction error. The app can build but when the button is pressed the error message comes up. The error message is in line “let videoURL = NSURL(fileURLWithPath: filePath!)”.

```
 import UIKit
 import AVKit
 import AVFoundation

 class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func playVideo(_ sender: UIButton) {

playLocalVideo()

}
func playLocalVideo(){
let filePath = Bundle.main.path(forResource: "t", ofType: "mp4")
let videoURL = NSURL(fileURLWithPath: filePath!)
let player = AVPlayer(url: videoURL as URL)
let playViewController = AVPlayerViewController()

playViewController.player = player
self.present(playViewController, animated: true) {() -> Void in playViewController.player!.play()

} } }

```
