Help Please! iPad detection not working

  • Hello all, I am trying to create a pano that detects whether the user has flash or ipad and then pulls up the appropriate navigation buttons (simple png buttons for ipad, interactive swf for flash). I have used some sample code I have found in this forum but it is not working. I have stared at it all weekend and still no luck. Hopefully it is something simple, but here are the approaches I have tried:

    Approach 1 - If/Then Statement

    Code
    <krpano version="1.0.8" onstart="if(ishtml5 , do_ishtml5() ); ">
    <action name="do_ishtml5"><style name="button" url="mbb11-buttons.png" keep="true" />
    		<plugin name="rotate" align="lefttbottom" x="10" y="10" style="button" crop="135|0|70|65" ondowncrop="135|65|70|65"  onup="switch(autorotate.enabled);"  devices="ipad"/>	    <plugin name="prev scene"  align="rightbottom" x="95" y="10" style="button" crop="65|0|70|65" ondowncrop="65|65|70|65"  onclick="prevscene();" devices="ipad"/> 		<plugin name="next scene"  align="rightbottom" x="10" y="10" style="button" crop="0|0|70|65" ondowncrop="0|65|70|65"  onclick="nextscene();"    devices="ipad"/>
    
    
    </action>Rest of code for non-html5....


    Approach 2 - Viewer detection on html file

    Code
    var viewer = createPanoViewer({swf:"krpano.swf", id:"krpanoSWFObject", target:"krpanoDIV"});
    	//viewer.useHTML5("whenpossible");		// incomment to use the HTML5 krpanoJS viewer always when possible (Safari5)
    	if( viewer.isDevice("iPhone|iPod|Android") )		viewer.addVariable("xml", "mbb-ipad.xml");	else		viewer.addVariable("xml", "mbb11-tipoff.xml");
    	viewer.embed();
    //	var swf = createswf("krpano.swf");	//swf.addVariable("xml","mbb11-tipoff.xml");	//swf.embed("krpanoDIV");

    For approach 1, it pulls up fine in flash version, and ipad pano is viewable, but the navigation buttons do not show up. For approach 2 I get an "Object expected" error with a reference to the line that beings "var viewer=...."

    Did I miss a semicolon or comma somewhere or is this more involved? Thanks to all who make this a great forum.

    - Louis G

    Edited once, last by ggarmen (March 28, 2011 at 3:50 PM).

  • Thanks Hans. I failed to mention it but devices was actually the first approach I tried. I tried devices=tablet, devices=ipad, devices=html5...nothing worked. Perhaps something with my krpano version is off, I will try a fresh install and see if that clears it up.

  • Made sure I had the latests release and still no luck. I even added the devices code to what is supposed to be the flash-only portion of the xml file and the buttons/plugins do not appear (even though the flash plugin does appear). The code I tried is below:

    Code
    <plugin name="rotate" align="lefttbottom" x="10" y="10" style="button" crop="135|0|70|65" ondowncrop="135|65|70|65"  onup="switch(autorotate.enabled);"  devices="ipad"/>	    <plugin name="prev scene"  align="rightbottom" x="95" y="10" style="button" crop="65|0|70|65" ondowncrop="65|65|70|65"  onclick="prevscene();" devices="ipad"/> 		<plugin name="next scene"  align="rightbottom" x="10" y="10" style="button" crop="0|0|70|65" ondowncrop="0|65|70|65"  onclick="nextscene();"    devices="ipad"/>


    Any other ideas?

  • Thanks Hans, fixed the error but the buttons still do not appear on ipad. If I put the plugin/buttons in a general section of the code applicable to both flash and html5, the buttons appear on both versions. But if I add the "devices=ipad" at the end of the plugin it does not appear in either version.

  • Sorry Jarredja, I am using the correct format (I think), as you can see in my code example above.

    As far as what I meant about the code, here is what I am trying to do:

    MAIN XML FILE
    Run action 1, 2..... for all panos regardless of device

    If ishtml5, also run actions from ipadxml.xml
    or
    if flash, also run actions flashxml.xml

    I've also tried doing something like:

    if ishtml5, do_ishtml5()...and then copying all the code from ipadxml.xml and pasting into the do_ishtml5 action.

    No matter what I try, I can't get it to detect ipad/html5 and display only on that device

  • Solved!!!!!

    I credit Hans. Turns out I must have installed one of the updates wrong. I completely started from scratch, re-downloaded, viewer, tools, my licenses, and latest beta version and now code works perfectly. Note to other newbies out there: correct files/updates will generate a .js file for each viewpoint when running Make Pano MultiRes. Before when I used that to make the panos it was only giving me an xml and html file.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!