I'm not sure, whether this is the right forum to discuss development issues. If not, please let me know or move it to the correct place.
I want to use Safari on iPad (latest iOS) to play my locally stored Panorama (with gyro support).
To my sorrow apple removed gyro support in safari (it's disabled and cannot be enabled anymore). And local file access is also forbidden (Sandbox).
Before someone will answer: "Just use garden gnomes package player": I tried, but this will not work. My package is about 4 Gigs with more than 700 panorama scenes. That the player cannot do (I hope for the future )
Now my idea is to create an own IOS application that hosts the safari (to be precise using the WKWebKit). Than I can feed in local files and can turn gyro on - Perfect idea, I thought.
So, Building the app was a day (first try with app local files, future plan is to attach the file app).
Now my problem: It seems that the index page (and the pano.xml) is loaded correctly - it's more a guess because there is not really a debugging support. I see a black page with the control bar. I can press the "I" icon and get the info of the first scene. After starting In the upper right corner I see 3 animated dots for some seconds (something like I'm working) but the page itself remains black.
Here's the code for clarification:
Code: Select all
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override var prefersStatusBarHidden: Bool {
return true
}
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
webView.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
webView.configuration.setValue(true, forKey: "allowsInlineMediaPlayback")
}
override func viewDidLoad() {
super.viewDidLoad()
// let myURL = URL(string:"https://SomeExternalServer/Pano2VR/360/index.html")
// let myRequest = URLRequest(url: myURL!)
// webView.load(myRequest)
let indexURL = Bundle.main.url( forResource: "index",
withExtension: "html",
subdirectory: "360")
if (indexURL != nil){
self.webView.loadFileURL( indexURL!,
allowingReadAccessTo: indexURL!.deletingLastPathComponent())
}
}
}
When I do that by using an external link it works correctly, so it must have something to do with the local stored files. (uncomment the 3 lines and comment out the lines after them:
Code: Select all
// let myURL = URL(string:"https://SomeExternalServer/Pano2VR/360/index.html")
// let myRequest = URLRequest(url: myURL!)
// webView.load(myRequest)
let indexURL = Bundle.main.url( forResource: "index",
withExtension: "html",
subdirectory: "360")
if (indexURL != nil){
self.webView.loadFileURL( indexURL!,
allowingReadAccessTo: indexURL!.deletingLastPathComponent())
}
best regards
Frank