Sie sind nicht angemeldet.

1

Montag, 28. März 2011, 05:11

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

Quellcode

1
2
3
4
5
<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

Quellcode

1
2
3
4
5
	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

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »ggarmen« (28. März 2011, 15:50)


HansNyb

Profi

Beiträge: 1 063

Wohnort: Denmark

Beruf: Photographer

  • Nachricht senden

2

Montag, 28. März 2011, 07:16

Why do you not use the devices settings in the xml. It is so amazingly simple.
And it works for almost all codes.
Plugins, hotspots , actions and more.
I also use is for the autorotate settings.

Just remember you need the last alpha beta version.
http://www.krpano.com/download/beta/

Hans

3

Montag, 28. März 2011, 14:21

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.

4

Montag, 28. März 2011, 15:40

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:

Quellcode

1
2
	     				<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?

HansNyb

Profi

Beiträge: 1 063

Wohnort: Denmark

Beruf: Photographer

  • Nachricht senden

5

Montag, 28. März 2011, 16:51

Error
align="lefttbottom"


should be
align="leftbottom"

Hans

6

Montag, 28. März 2011, 16:58

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.

7

Montag, 28. März 2011, 17:32

Are you really putting

"devices=ipad"

Or the proper format

devices="ipad"

And what do you mean by the part of the code that is designated for html5 vs flash.

8

Montag, 28. März 2011, 17:43

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

9

Montag, 28. März 2011, 22:54

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.