Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

1

Mittwoch, 12. Juli 2023, 07:06

in "oncomplete" cannot access parent variable - caller.

!! UPDATE !!
I'm using krpano ver. 1.20.11.
------------------

I don't know exactly when it started 'oncomplete' running differently.
I think it could be from krpano ver. 1.20 updates which had had replaced its sound interface from HTML5-Audio to webAudio API.
--- if possible, I'd like to know when it started exactly just for information.



- this action works as usual : playsound(_name_, _source_, false, 1, oncomplete() );


But in a local scope action, the 'oncomplte' cannot access caller.
'caller' is not the caller itself who acually called the action, but trace() shows null.

Quellcode

1
2
3
<action autorun='onstart'>	callwith(hotspot[anhotspot], anaction);</action>
<hotspot name='anhotspot' />
<action name='anaction' scope='local'>	trace(caller.name); // anhotspot	playsound(_name_, _source_, false, 1, trace(caller.name) ); // undefined or null</action>



in that case, if you needed get the extra information from the caller - the hotspot named 'anhotspot' is NOT possible in 'oncomplete'.

Yes, in different way, it could be solved problem,
However, I'd like to know if there's another way to get the action caller in easy way OR it's impossible to be accessed.

Thanks.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Kabkee« (12. Juli 2023, 08:34)


2

Mittwoch, 12. Juli 2023, 08:28

playsound(_name_, _source_, false, 1, trace(get(caller.name)) );

Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

3

Mittwoch, 12. Juli 2023, 08:32

playsound(_name_, _source_, false, 1, trace(get(caller.name)) );

Unfortunately, that's not the point.
did you tried that in scope='local' action as i mentioned above?
it's not the matter of using get() though.

if it's the matter of using get(), I didn't post it at all.

4

Mittwoch, 12. Juli 2023, 08:38

trace(caller.name); shows "anhotspot" as expected when you call the action with callwith()
its kind of logical that the playsound callback cant have anaction or anhotspot...
1) its not called from anaction() but from playsound()
2) such a callback is not a local scope action
but you can pass any information when you create/pass the callback

maybe that works:
calc(local.callback, "trace("+caller.name+")");
playsound(_name_, _source_, false, 1, get(callback));

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »indexofrefraction« (12. Juli 2023, 09:00)


Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

5

Mittwoch, 12. Juli 2023, 09:36

trace(caller.name); shows "anhotspot" as expected when you call the action with callwith()
its kind of logical that the playsound callback cant have anaction or anhotspot...
1) its not called from anaction() but from playsound()
2) such a callback is not a local scope action
but you can pass any information when you create/pass the callback

maybe that works:
calc(local.callback, "trace("+caller.name+")");
playsound(_name_, _source_, false, 1, get(callback));

Thank you for your prompt response.
and you right mentioned that's why I'm finding a way to get access some variables out of the local scope of playsound's 'oncomplete'.

I know there's no anaction, no anhotspot in the scope of 'oncomplete', it makes me feel like it's so much isolated from other scopes.
But, it can access to "global" !!

The following code works:

Quellcode

1
2
3
4
5
<action name='anaction' scope='local'>
trace(caller.name);
copy(global.callerName, caller.name);
playsound(narration, get(sound_source[effect_popup].url), false, 1, trace(get(global.callerName)) );
</action>



However, it's not the way what I do NOT want.
So, here's my solution. make a xml element and using its' attribues like below:

Quellcode

1
2
3
4
5
6
<some_setting tempcaller='' />
<action name='anaction' scope='local'>
trace(caller.name);
copy(some_setting.tempcaller, caller.name);
playsound(narration, get(sound_source[effect_popup].url), false, 1, trace(some_setting.tempcaller) );
</action>



As you expected, the above codes are work properly.



Unfortunately, your codes below are not working.

Quellcode

1
2
3
maybe that works:
calc(local.callback, "trace("+caller.name+")");
playsound(_name_, _source_, false, 1, get(callback));




Maybe.. or somehow, there could be a better solution to get access to caller from oncomplete???
*whistling* *rolleyes* *confused*






6

Mittwoch, 12. Juli 2023, 10:21

strange.. it works fine here
proof of concept -->

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<action autorun='onstart'>
	callwith(hotspot[myhotspot], myaction);
</action>
<hotspot name='myhotspot' />
<action name='myaction' scope='local'>
	trace('myaction() caller.name=',caller.name);
	calc(local.callback, "trace('callback() "+caller.name+"')");
	action_with_callback(get(callback));
</action>
<action name='action_with_callback' scope='local' args="callback">
	trace('action_with_callback() callback=',callback);
	callback();
</action>

Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

7

Donnerstag, 13. Juli 2023, 07:08

strange.. it works fine here
proof of concept -->

Quellcode

1
2
3
4
5
6
7
8
9
10
11
	callwith(hotspot[myhotspot], myaction);



	trace('myaction() caller.name=',caller.name);
	calc(local.callback, "trace('callback() "+caller.name+"')");
	action_with_callback(get(callback));


	trace('action_with_callback() callback=',callback);
	callback();

Thank you for your example. it works. Yes, I know.
But ah...

I got to know that I mistitled this post and I should had to mention the words "oncomplete of playsound - SoundInterface"


I re-point that
"I want a way to get caller of local scoped action which called from a hotspot in oncomplete of ""playsound"" action."

There's no way so far, and i wrote this post.
AND I'm finding other's opinions, its possibilities, or the exact reason why it is.


""I hope that you tried my code which mentioned the beginning.
specially, have your attention on "playsound" action and in the oncomplete session, you cannot get any caller in there.""

8

Donnerstag, 13. Juli 2023, 07:38

Hello friends,

maybe this post is related to my post I have just written:

https://krpano.com/forum/wbb/index.php?page=Thread&threadID=19413

Is this what kabkee is talking about?


Cheers,
hyung

9

Donnerstag, 13. Juli 2023, 09:52

it doesnt matter playsound or other, you can not trace back the caller history
the callback (oncomplete) is called from playsound() and you can't get a higher caller
the trick to hardcode the caller (or any information) into the callback is a workaround
it works the exactly same for playsound as for the example

Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von »indexofrefraction« (13. Juli 2023, 10:12)


Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

10

Donnerstag, 13. Juli 2023, 10:47

OK.
As you called the 'oncomplete' as a "callback", YES I think it's real javascript callback function which could not access other territories, variables.
Specially, in such a limited environment like krpano javascript type action. (Somehow, it works so in krpano to get intergrated with pure Javascript library - hower js)


As Hyung mentioned in the thread - https://krpano.com/forum/wbb/index.php?p…&threadID=19413
The two different callback - "donecall" and "oncomplte" - look like the same, but work differently.


Then, could I make the conclusion of this tread?

Why I made this tread is to get access caller (in local scoped action) in oncomplete(callback function of playsound, Sound Interface).
However, it's not possible to get the history of callback because of the mechanism or so.




Related to this thread,
one thing left question driven from Hyung is that.


1. HOW donecall of tween and oncomplete of playsound (sound interface) are differently working in Krpano?

2. WHAT makes donecall of tween and oncomplete of playsound (sound interface) work different in the same situation?





I'd like to get your opinion or advice to use them correctly with right knowledge.
Thank you in advance.







11

Donnerstag, 13. Juli 2023, 20:39

@ Kabkee
sorry this is not a simple topic...
but keep in mind that there are actions without or with (local) scope and then there is callwith() which is not the same!
local scope actions use the caller object, actions called with callwith() work differently
eg. callwith(hotspot[abc], trace(name)); will trace the hotspots name
instead of searching the variable in the globals, it is searched in the hotspot/layer first.
event functions for layers and hotspots (like onclick) use that 2nd approach
callwith(hotspot[abc], myaction()); or with <hotspot ... onclick="myaction()" .../>
will set the caller object, if myaction is a local scope action.
otherwise myaction() can use the hotspots attributes directly, like globals.
as said its not a simple topic and in the end you must test things out
anyway, in any case only the direct caller is accessible! you cant get a higher caller

12

Donnerstag, 13. Juli 2023, 20:41

@ Kabkee
sorry this is not a simple topic...
but keep in mind that there are actions without or with (local) scope and then there is callwith() which is not the same!
local scope actions use the caller object, actions called with callwith() work differently
eg. callwith(hotspot[abc], trace(name)); will trace the hotspots name
instead of searching the variable in the globals, it is searched in the hotspot/layer first.
event functions for layers and hotspots (like onclick) use that 2nd approach
callwith(hotspot[abc], myaction()); or with <hotspot ... onclick="myaction()" .../>
will set the caller object, if myaction is a local scope action.
otherwise myaction() can use the hotspots attributes directly, like globals.
as said its not a simple topic and in the end you must test things out
anyway, in any case only the direct caller is accessible! you cant get a higher caller
thats why the example above hardcodes the callers name inside the callback function
this way you have the needed information

Kabkee

Schüler

  • »Kabkee« ist der Autor dieses Themas

Beiträge: 116

Wohnort: South Korea

Beruf: South Korea

  • Nachricht senden

13

Freitag, 14. Juli 2023, 11:42


@ Kabkee
anyway, in any case only the direct caller is accessible! you cant get a higher caller
thats why the example above hardcodes the callers name inside the callback function
this way you have the needed information
Yes. that makes me sense. All about the local scope and callwith you said, I agree with them.
To make simple the topic of this thread, I brought a new sample code below.

Today I have a deep thinking time on this, and I got an idea *w00t* *attention* why it is.
My guess is that It is because "klaus make this so".
I don't know it's in purpose or not, but please review the blow code.


Playsound oncomplete, tween donecall works the same.
All returns "got YOU".

Quellcode

1
2
3
4
5
6
7
8
9
<action name='anaction'>
	set(getMyName, 'got YOU');
	tween(view.hlookat, 90,,,
		trace(getMyName); // got YOU
	);
	playsound(narration, get(sound_source[effect_popup].url), false, 1,
		trace(getMyName); // got YOU
	);
</action>



Playsound oncomplete, tween donecall works differently.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<action autorun='onstart'>
	callwith(hotspot[anhotspot], anaction);
</action>

<hotspot name='anhotspot' />

<action name='anaction' scope='local'>
	copy(getMyName, caller.name);
	tween(view.hlookat, 90,,,
		trace(get(getMyName)); // anhotspot	);
	playsound(narration, get(sound_source[effect_popup].url), false, 1,
		trace(get(getMyName));  // null 	);
</action>



My Guess,
1. tween is genuine krpano action and its donecall works remaining in krpano.
2. playsound is a plugin action which is integrated with howlerJs.
3. In the code of integration, (maybe) in the listening event callback function don't get any information because the callback function is running in an isolated function which is in static mode.


What do you think?

I think. Only Klus can reveal the fact how this possible.
I'm just curious and this has not been solved clearly for few days :(