I'm trying to play a local video with this player I found online and this is the code that deals with getting the URL of the video. It appears it works for local videos but when I try it doesn't work.
private var filepath: String!
public var path: String! {
get {
return filepath
}
set {
// Make sure everything is reset beforehand
if(self.playbackState == .Playing){
self.pause()
}
self.setupPlayerItem(nil)
filepath = newValue
let remoteUrl: NSURL? = NSURL(string: newValue)
if remoteUrl != nil && remoteUrl?.scheme != nil {
let asset = AVURLAsset(URL: remoteUrl!, options: .None)
self.setupAsset(asset)
} else {
let localURL: NSURL? = NSURL(fileURLWithPath: newValue)
let asset = AVURLAsset(URL: localURL!, options: .None)
self.setupAsset(asset)
}
}
}
I put this code in another view controller where I want the video to run and set the path to the URL variable declared below...
let path = NSBundle.mainBundle().pathForResource("VideoName", ofType: "mov")
And it doesn't work for some reason. I'm most likely doing something wrong. What's going on? Reply if you need any more information. Thanks!