Hello,
I'm developing a Xamarin.Forms application, which contains a WebView that holds krpano HTML5 viewer. I'm focusing on Android 7.1 right now.
The goal is to implement a simple 360 panora viewer, so the xml config file is very simple : just a simple sphere component.
If the image is loaded from internet, everything works fine and easy (but if I need to specific html5: "always" to make it work, and localfallback: "none" to remove the "file:///" warning).
But the hard part is when loading image from the local device drive, using the "file://" protocol.
It simply won't work, showing just black, no error message...
To be sure it isn't a file access permission problem, I've added a <img> component in the html pointing the exact same image locally and it work just fine.
To be sure it isn't a javascript permission problem, I've tried to load the same image not using the scr tag of <img>, but using a small js script, and it work just fine.
So know I have no lead or no idea why krpano doesn't want to load the picture, and I've isolated the problem to be sure it's coming from krpano and not another component.
To help please find a simple source code below. Please note that for simplicity, I've embedded the xml into the html to remove one file (works fine with a online image).
<script src="krpano.js"></script>
<p id="cn"> Simple label showing the html page is loaded </p>
<img src="file:///storage/emulated/0/Download/pano2.jpg" alt="" width="200" height="30">
<div id="pano"></div>
<script>
// global krpano interface (will be set in the onready callback)
var krpano = null;
// embed the krpano viewer into the 'pano' div element
embedpano({
xml: null,
target: "pano",
html5: "always",
localfallback: "none", //Ignore that they are local restrictions and start the HTML5 viewer anyway...
passQueryParameters: true,
onready: krpano_onready_callback
});
// callback function that will be called when krpano is embedded and ready for using
function krpano_onready_callback(krpano_interface) {
krpano = krpano_interface;
loadXml("<krpano><preview type="grid(cube, 64, 64, 512, 0xCCCCCC, 0xF6F6F6, 0x999999);" /></krpano>");
}
//Load new pano image-
function loadImage(imageName) {
if (krpano) {
krpano.call("loadpano(krpano.xml, filename=" + imageName + ", MERGE, BLEND(0.5));");
}
}
function loadXml(xml) {
if (krpano) {
//This line works fine, showing a empty grid environment.
//krpano.call("loadxml('" + xml + "')");
//This line doesn't load the local image
krpano.call("loadxml('<krpano><image><sphere url="file:///storage/emulated/0/Download/pano2.jpg"/></image></krpano>')");
}
}
</script>
Display More
Do you have any ideas how to solve that not-so-simple problem ?
(I'm using krpano-1.19-pr14)
Thanks.
Nicolas.