I'm developping an App for IOS runnign with Swift to play some video and image in a player;
I'm calling the file for the video like:
videoView.displayMode = GVRWidgetDisplayMode.fullscreen
and for an image:
imageView.displayMode = GVRWidgetDisplayMode.fullscreen
I'd like to have a if statement, like;
if file being call is .png launch it via the imageViewer;
if file is mp4, launch it via the videoviewer
I'm calling the file locally ( being perviously downloaded via:
let urlString = "\(postslogin[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)
)
The code added above is being call from the super.viewDidLoad.
Any suggestions will be super !
Thanks :) :)
--- EDIT NEW ---
So far I've try :
let urlString = "\(postslogin[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)
if (fileURL.pathExtension == "jpg") {
imageVRView.load(UIImage(named: "\(documentsPath)/\(fileName.lastPathComponent)" ),
of: GVRPanoramaImageType.mono)
imageVRView.displayMode = GVRWidgetDisplayMode.fullscreen
}
else if (fileURL.pathExtension == "mp4") {
videoVRView.displayMode = GVRWidgetDisplayMode.fullscreen
videoVRView.load(from: URL((fileURLWithPath: filePath))
)
}
without success :( :(