swift - Play video from local file with tvOS -


i want play little video (20 seconds) when app opens on apple tv. can't find how implement url local file.

this i've got far, unfortunately doesn't work:

    override func viewdidload() {         super.viewdidload()          // know how play file webserver:         // player = avplayer(url: nsurl(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!)          // can't find how set url local file in app         let path = nsbundle.mainbundle().pathforresource("bunny", oftype:"mp4")         let url = nsurl.fileurlwithpath(path!)         player = avplayer(url: url)          player?.play()      } 

your code seems fine. maybe, should try this:

in project navigator select project root > target > build phases > copy bundle resources. check see video there, if not click plus sign add it.

source: http://www.brianjcoleman.com/tutorial-play-video-swift/


Comments