You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

1

Tuesday, September 15th 2009, 6:02pm

easy way to access to a pano ?

Hi,

Let's say I'm on virtual tour where there is 15 panos.

I'd to know if there is an easy solution to access to one pano directly with url (without having 15 html and xml files...) ?

Something like http://www.mytour.com/index.html#pano12

Is there a way to use the # anchor with swfobject v2 ?

Thanks
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Tuesday, September 15th 2009, 9:15pm

Hi nelk,

Yes, there is a way to do using javascript to retrieve a variable from the URL...
Ex: YourDomain.com/PanoTour?pano=panoToBeLoaded

I have used, as the base to illustrate the following, the scene example that come with Krpano_1.0.8 download.
In the scene.xml example, there is an action(onstart) called by the Krpano.onstart argument...
The action(onstart) is as follow:

Source code

1
2
3
<action name="onstart">
   loadscene(scene1, null, MERGE);
</action>

This action loads the scene to be loaded...
Then, using a javascript that retrieve the variable pano from the URL, in the scene.html file we go to change dynamically the content of this action with the scene we need to be loaded.
Like this: so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");

The resulting scene.html file will be:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<title>krpano.com scenes example</title>

<script type="text/javascript">
pano = "scene1";   // Default pano to be loaded if not set in the URL
searchVariables = location.search.substring(1,location.search.length);
if (searchVariables!="") {
arrVariables = searchVariables.split("&");
for (i=0; i<arrVariables.length; i++) {
arrVariableActual = arrVariables[i].split("=");
if (isNaN(parseFloat(arrVariableActual[1])))
eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
else
eval(arrVariableActual[0]+"="+arrVariableActual[1]+";");
}
}
</script>

</head>
<style>
body{ font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#FFFFFF; background-color:#000000; margin:0; padding:0; }
* html, * html body{ overflow: hidden; }
a{ color:#AAAAAA; text-decoration:underline; }
a:hover{ color:#FFFFFF; text-decoration:underline; }
</style>
<body>

<div id="krpanoDIV">
<noscript><table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br/><br/>Javascript not activated<br/><b/r></center></td></tr></table></noscript>
</div>

<script type="text/javascript" src="../../swfobject/swfobject.js"></script>
<script type="text/javascript" src="../../swfobject/swfkrpanomousewheel.js"></script>


<script type="text/javascript">
// <![CDATA[
if (typeof(deconcept) !== 'undefined')
{
 if (deconcept.SWFObjectUtil.getPlayerVersion().major >= 9)
{
var so = new SWFObject("../../krpano.swf","krpanoSWFObject","100%","100%","9.0.28","#000000");
so.addParam("allowFullScreen","true");

so.addVariable("xml", "scenes.xml");
so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");

if (so.write("krpanoDIV")) { var mousewheelfixes = new SWFkrpanoMouseWheel(so); }
}
else
{
document.getElementById("krpanoDIV").innerHTML = '<table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br><br>Adobe Flash Player 9 needed<br><br><br><a href="http://www.adobe.com/go/getflashplayer/"  target="_blank"><IMG SRC="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" BORDER="1"></a><br>...click here to download...<br><br><br><br></center></td></tr></table>';
}
}
else
{
document.getElementById("krpanoDIV").innerHTML = '<table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br/><br/>swfobject.js not found<br/><br/></center></td></tr></table>';
}
// ]]>
</script>

</body>
</html>

Lines 5 to 18 are the javascript code that retrieve the variables from the URL...
Note the line 6.... here you set the default value to the variable pano if it is not set on the URL.
Line 47... this is the line that change the action[onstart].content

That's all. ;-)


note: this thread Banner without XML has helped me to get this code.

Salut.

This post has been edited 1 times, last edit by "michel" (Sep 15th 2009, 9:44pm)


nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

3

Tuesday, September 15th 2009, 11:16pm

Salut :-)

Thanks for your answer

I've few questions :


- For the code between line 7 and line 17 : I assume that arrVariableActual[0] is equal to pano ?

(I don't really understand javascript ...)


- on line 46 you have

Source code

1
so.addVariable("xml", "scenes.xml");


I had never see xml before in a variable.

Is there a difference between pano and xml ? Is variable xml more like include ?
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

4

Tuesday, September 15th 2009, 11:18pm

Is there a difference between pano and xml ? Is variable xml more like include ?


Hum ... for this question, I think I've found a solution myself in this topic : pano and xml are the same.
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

5

Wednesday, September 16th 2009, 12:01am

Hi nelk,

Quoted

- For the code between line 7 and line 17 : I assume that arrVariableActual[0] is equal to pano ?

I am not an expert... But I am going to explain what I understand here... *whistling*

Ex: YourDomain.com/PanoTour?pano=panoToBeLoaded&var2=value&var3=value&etc....

Code line 7 : searchVariables = location.search.substring(1,location.search.length);
result: searchVariables = pano=panoToBeLoaded&var2=value&var3=value&etc....


Code line 9 : arrVariables = searchVariables.split("&");
result: arrVariables[0] = pano=panoToBeLoaded
arrVariables[1] = var2=value
arrVariables[2] = var3=value
arrVariables[3] = etc....

Code line 10 : for (i=0; i<arrVariables.length; i++) {
going to make a buckle for each existing arrVariables[X]

Code line 11 : arrVariableActual = arrVariables.split("=");
result: arrVariableActual[0] = pano when on the first buckle
arrVariableActual[1] = panoToBeLoaded when on the first buckle
.....
arrVariableActual[0] = var2 when on the second buckle
arrVariableActual[1] = value when on the second buckle (edited: when on the first buckle)
and so on.....

Code line 13 :eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
this line is the one declare the variable=value
result:pano = panoToBeLoaded

Now, we have the variable pano to use in :
so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");


Basically, this is what the javascript code dones....


Quoted

- on line 46 you have .....

Source code

1
1 so.addVariable("xml", "scenes.xml");


This is the code KLAUS use on his scene.html code ....

Hope I am understandable.... *blink* *g* (Really bad English)

Salut.

This post has been edited 2 times, last edit by "michel" (Sep 17th 2009, 4:09am)


michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Wednesday, September 16th 2009, 12:22am

Hi nelk,

Try changing the scene.html from KLAUS scene example with the one above....

Open it (it will open the first scene) and add in the URL the_URL_to_sceneExample?pano=scene2 and reload...
It will open the second scene *attention* ;-)

Salut.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

7

Friday, September 18th 2009, 3:58am

Hi nelk,

Have you found a way to do what you was looking for? If so, How? *rolleyes* I would like to know.. *thumbup*

Salut.

8

Friday, September 18th 2009, 10:27am

Hi,

thanks michel!
I was going to write the same

have also a look at the source code of krpano.html here - http://krpano.com/krpano.html
it works similar,

best regards,
Klaus

9

Thursday, January 14th 2010, 4:02pm

Hi,

I would like to achieve this (so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");) with swfobject 2.2.

I tried this (line 5):

Source code

1
2
3
4
5
6
7
swfobject.embedSWF("krpano.swf", "panoramaDiv", 
"100%", "100%", "9.0.28", 
"basis/expressInstall.swf", 
{pano:"pano/heuvel.xml"},
{"action[onstart].content":"loadscene(" + pano + ", null, MERGE);"},
{allowfullscreen:true, bgcolor:"#000000"}, 
{id:'panoramaDiv', name:'panoramaDiv'});


...but it doesn't work. Any ideas?


Edit: already found out. Has to be like this:

Source code

1
2
3
4
5
6
swfobject.embedSWF("krpano.swf", "panoramaDiv", 
"100%", "100%", "9.0.28", 
"basis/expressInstall.swf", 
{pano:"pano/heuvel.xml", "action[onstart].content":"loadscene(" + pano + ", null, MERGE);"},
{allowfullscreen:true, bgcolor:"#000000"}, 
{id:'panoramaDiv', name:'panoramaDiv'});

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

10

Thursday, January 14th 2010, 4:17pm

Hi photo40,

edited: Forget this... see edited above.
Perhaps you can try in this way (just an idea, I have not tried):

Source code

4
{pano:"pano/heuvel.xml?action[onstart].content=loadscene(' + pano + ', null, MERGE);"},


SAlut.

This post has been edited 1 times, last edit by "michel" (Jan 15th 2010, 7:31pm)