Here is my situation: i'm calling file locally on my ios application ( Running in Swift).
If the file is a jpg, one action happen, if the file is a mp4, another action happen.
For this i'musing this code:
let urlString = "\(posts[selectedIndexPath].link)"
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let fileName = urlString as NSString;
let filePath="\(documentsPath)/\(fileName.lastPathComponent)";
let fileURL = NSURL.init(fileURLWithPath: filePath)
let request = NSURLRequest.init(url: fileURL as URL)
/* END DOWNLOAD + READ LOCALY */
if (fileURL.pathExtension?.hasPrefix("jpg"))! {
Swift.print("THIS IS A JPG")
}
else if (fileURL.pathExtension == "mp4") {
Swift.print("THIS IS A MP4")
}
This works perfectly.
What i need to do now is instead of calling th eifle locally, to calling it form an URL.
I read my file from an url by:
videoVRView.load(from: URL(string: "\(posts[selectedIndexPath].link)")
Which work.
But from that, the action is not working, i've try the following:
if ((from: URL(string: "\(posts[selectedIndexPath].link)").hasPrefix("jpg"))! {
Swift.print("THIS IS A JPG")
}
else if ((from: URL(string: "\(posts[selectedIndexPath].link)") == "mp4") {
Swift.print("THIS IS A MP4")
}
Without any success !!
Does anybody know how is this achievable ?
Thanks a lot =)
-- EDIT --
What im trying to do is th efollowing to resume:
at th emoment i call image locally via:
imageVRView.load(UIImage(named: "\(documentsPath)/\(fileName.lastPathComponent)" ),
of: GVRPanoramaImageType.stereoOverUnder)
I try instead to use:
imageVRView.load(UIImage(named: "\(posts[selectedIndexPath].link)" ),
of: GVRPanoramaImageType.stereoOverUnder)
Without success . . . . I need to call the image via this method ... any idea ? Thanks a lot !