• your example is wrong :

    Code
    if(layer[layerx].html, 'pause▐▐ ', set(layer[layerx].html, Play ▶ ));

    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:

    Code
    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);

    Code
    calc(layer[layerx].html, layer[layerx].html ===  'pause▐▐ ' ?  'Play ▶ ' : 'pause▐▐ ');

    or switch

    Code
    switch(layer[layerx].html, 'pause▐▐ ', 'Play ▶ ');
  • 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

    Code
    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).

    Code
    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)

    Code
    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

    Code
    set(layer[xtUfer_4].onclick, pausesoundtoggle(xtUfer); 
    set(layer[xtUfer_4].html, 'Play ▶ '););

    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)

    Hall360Tirol Brockenweg


    here is the code that transforms the text hotspots into the desired audio hotspots

    the play pause switch is now in the if(sound[xtUfer].paused, action placed. it doesnot work even

    Edited once, last by nikonutsch (January 24, 2025 at 8:18 AM).

  • "," 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:

    Code
    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:

    Code
    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 ";"


    see https://krpano.com/docu/actions/#if

Participate now!

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