Callback never called in Viewer contructor

david.thibault
Posts: 7
Joined: Fri Dec 09, 2016 2:40 pm

Callback never called in Viewer contructor

Postby david.thibault » Fri Dec 09, 2016 4:07 pm

Hi,
I would like to be notified when the player is ready.
I can see in your doc http://kenstreams.kolor.com/data/releases/0.1.0/doc/jsdoc/KEN.Viewer.html :

Code: Select all

new Viewer(parent, config, callbacks)

In my example, the onReadyCb function is never called.

Code: Select all

<script src="http://kenprivatebeta.kolor.com/releases/0.1.0/build/ken.min.js"></script>
<script type="text/javascript">
   var onReadyCb = function(e) {
          console.log('ready', e);
   };
   var viewer = new KEN.Viewer("container", "config.json", onReadyCb);
</script>

Do you have any idea ?
Thanks.

User avatar
rroux
ForgeJS Team
Posts: 108
Joined: Wed Oct 26, 2016 12:19 pm

Re: Callback never called in Viewer contructor

Postby rroux » Tue Dec 13, 2016 2:51 pm

Hi David,

In fact callbacks parameter is an object with two properties "boot" and "update" so you can specify both of them BUT boot does not mean that the viewer is ready. Here is an example of how it works for the third callbacks parameter.

  1. var viewer = new KEN.Viewer("container", "config.json", {boot: bootCallback, update: updateCallback});


Anyway, these callbacks will be remove in a future version so I don't recommend to use them.
For the onReady event you should try something like this :

  1. var viewer = new KEN.Viewer("container", "config.json");
  2. viewer.onReady.add(onReadyHandler);
  3.  
  4. function onReadyHandler()
  5. {
  6.     //Your ready code goes here!
  7. }


Hope this will help you!
- Raphaël

david.thibault
Posts: 7
Joined: Fri Dec 09, 2016 2:40 pm

Re: Callback never called in Viewer contructor

Postby david.thibault » Tue Dec 13, 2016 3:55 pm

Thanks Raphaël,
Yes it helped me.
David.

Who is online

Users browsing this forum: No registered users and 2 guests