Player icon indicating copy to clipboard operation
Player copied to clipboard

load video with data

Open jose920405 opened this issue 9 years ago • 4 comments

jose920405 avatar Dec 18 '15 16:12 jose920405

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)

sentiasa avatar Dec 19 '15 09:12 sentiasa

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.

HarukaMa avatar Jan 30 '16 12:01 HarukaMa

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?

OverlappingElvis avatar Aug 10 '16 18:08 OverlappingElvis

📎 https://github.com/piemonte/Player/issues/17

piemonte avatar Sep 08 '19 20:09 piemonte