dear forum
how to do this.....
if(layer[layerx].html, 'pause▐▐ ', set(layer[layerx].html, Play ▶ ));
wbr klaus
dear forum
how to do this.....
if(layer[layerx].html, 'pause▐▐ ', set(layer[layerx].html, Play ▶ ));
wbr klaus
Instead of if() you can just use switch() to toggle between the states.
thanks, i know.
the else action isn't always toggle-able like in this example .
if(layer[layerx].html, 'pause▐▐ ', else any action
your example is wrong :
means: if layer[layerx].html is not an empty string, then <wrong syntax here>, else set html to play
you would need to change this to:
if(layer[layerx].html === 'pause ▐▐ ',
set(layer[layerx].html, 'Play ▶ ');
,
set(layer[layerx].html, 'pause ▐▐ ');
);
---> documentation here : https://krpano.com/docu/actions/#if
or use the ternary operator --> calc(destination, condition ? if value : else value);
or switch
thanks, i know.
the else action isn't always toggle-able like in this example .
if(layer[layerx].html, 'pause▐▐ ', else any action
Yeah it is. See example stated by you bye indexofrefraction. It's just critical to add it add the right place in your actions ![]()
I should have expressed myself more precisely.
The else actions are very different in my case......not exclusively like in the example at the beginning.
That's why I wanted to know how to represent the syntax in this case as an if (action). But thanks for the help anyway
if(layer[xtUfer_4].html === 'pause ▐▐ ',
set(layer[xtUfer_4].html, 'Play ▶ ');
,
set(layer[xtUfer_4].padding,10);
set(layer[xtUfer_4].roundedge,20);
set(layer[xtUfer_5].visible,false););
However, in this particular case I am faced with an absolute puzzle. In this case I did indeed start with a switch(action).
set(layer[xtUfer_4].onclick, pausesoundtoggle(xtUfer);
switch(layer[xtUfer_4].html, 'Play ▶ ', 'Pause▐▐ '););
after that didn't work, I tried to solve the problem with an if(action)
set(layer[xtUfer_4].onclick, pausesoundtoggle(xtUfer);
if(layer[xtUfer_4].html === 'pause ▐▐ ',
set(layer[xtUfer_4].html, 'Play ▶ ');
,
set(layer[xtUfer_4].html, 'pause ▐▐ '););)
after all that didn't work, I tried replacing the swich(action) with a simple set(action) for test purposes, which surprisingly worked
In the meantime I have tried a different approach; unfortunately, just as unsuccessfully.
I have decided to upload the example I am working on so that it is not so abstract.
In this project we use an auditour for the first time. Switchable with the button gotoAudiotour (screenright)
here is the code that transforms the text hotspots into the desired audio hotspots
onresize="calc(hotspot[xtUfer].ath_sound,hotspot[xtUfer].ath + 15);
callwhen(hotspot[xtUfer].audio == true,
set(layer[xtUfer_33].height,40);
set(layer[xtUfer_4].padding,10);
set(layer[xtUfer_4].roundedge,20);
set(layer[xtUfer_4].html,);
set(layer[xtUfer_5].visible,false);
set(layer[xtUfer_4].onclick, pausesoundtoggle(xtUfer); );
if(sound[xtUfer].paused, set(layer[xtUfer_4].html, 'Pause ▶') , playsound_at_hv(xtUfer,'get(hotspot[xtUfer].audio_url)',get(hotspot[xtUfer].ath_sound),0,100,false,1,30, ); set(layer[xtUfer_4].html, 'Pause▐▐') );
callwhen(hotspot[xtUfer].audio == false,
destroysound(xtUfer);
set(layer[xtUfer_33].height,get(hotspot[xtUfer].vector_height));
set(layer[xtUfer_4].padding,4);
set(layer[xtUfer_4].roundedge,0);
set(layer[xtUfer_4].html, get(hotspot[xtUfer].primus));
set(layer[xtUfer_5].visible,true);
set(layer[xtUfer_4].css, 'color:#fff;font-size:14px;');
set(layer[xtUfer_4].backgroundcolor,get(hotspot[xtUfer].primus_color));
set(layer[xtUfer_4].onclick,get(hotspot[xtUfer].ziel));))"
Display More
the play pause switch is now in the if(sound[xtUfer].paused, action placed. it doesnot work even
"," is the separater for the if(check, true, false) statement, so your current code would be incorrect syntax wise
so if you apply this to your current code, it would look like this:
if(sound[xtUfer].paused, << check
>> true set(layer[xtUfer_4].html, 'Pause ▶') ,
>> false playsound_at_hv(xtUfer,'get(hotspot[xtUfer].audio_url)',
>> incorrect syntax >> get(hotspot[xtUfer].ath_sound),0,100,false,1,30, ); set(layer[xtUfer_4].html, 'Pause▐▐') );
and will cause everything else after this statement to be ignored.
so adjust your code to something like this:
if(sound[xtUfer].paused,
set(layer[xtUfer_4].html, 'Pause ▶');
playsound_at_hv(xtUfer,'get(hotspot[xtUfer].audio_url)';
get(hotspot[xtUfer].ath_sound),0,100,false,1,30, );
,
set(layer[xtUfer_4].html, 'Pause▐▐');
);
Basically, replace your "," with ";"
sorry but i think
playsound_at_hv(xtUfer,'get(hotspot[xtUfer].audio_url)',get(hotspot[xtUfer].ath_sound),0,100,false,1,30,oncomplete )
is correct
playsound_at_hv(name, url, h, v, depth, loop, volume, range, oncomplete)
'get(hotspot[xtUfer].audio_url)'
putting that in quotes is certainly wrong
Ah, yes, also true, I overlooked that as the question was about the "if" syntax. Good catch too!
'get(hotspot[xtUfer].audio_url)'
putting that in quotes is certainly wrong
dear ior
Interestingly, it works the same with or without the quotation marks. It has no effect on the original problem whether I remove the ' ' or leave it. I have removed the quotation marks here just in case.
wbr klaus
that is strange.. krpano should not interpret the contents of a string. .. Klaus ?
Don’t have an account yet? Register yourself now and be a part of our community!