Player
Player copied to clipboard
load video with data
You didn't include any description, but I am posting my problem with local data.
I tried using this method, but doesn't work for me. What I did:
- Downloaded video from Vine & called it aaa.mp4
- Drag/Drop it in project
- Added File to Copy Bundles Resources
- Then, at the top of ViewController, I added:
let path = NSBundle.mainBundle().pathForResource("aaa", ofType:"mp4")!
let videoUrl = NSURL(string: path)!
Also, when I put print(path) in ViewDidLoad, it gives me the path:
/Users/sent/Library/Developer/CoreSimulator/Devices/67160785-1BDB-4046-BD58-A8C448938A4F/data/Containers/Bundle/Application/00750449-71AC-45E5-B74D-B5FA1A516D18/Player.app/aaa.mp4
(Please note that, if I give the path a filename that doesn't exists, it throws nil; so I know the video exists)
And solved it with let videoUrl = NSURL(fileURLWithPath: path)
I think he means loading NSData as video data?
However it seems that you need to write the data into disk in order to play it.
I'm caching static resources (images, audio, and video) using HanekeSwift so when I retrieve them they're just NSData and do not have a URL associated. @piemonte I see the enhancement tag, do you think this is something you will support? Alternatively, is there a good way to generate a URL without having to write the already cached file to disk?
📎 https://github.com/piemonte/Player/issues/17