Controlling KDP from JavaScript

8 replies [Last post]
Joined: 05/06/2009
Points: 9

We're looking at using JavaScript to control an embedded Kaltura player. So, I turned to the wiki pointed example:

http://kaldev.kaltura.com/projects2009/kdp_js_api.html

Is this still the recommended method for organizing the javascript code to connect and control to the KDP object?

When I compare it to the approach here:

http://corp.kaltura.com/wiki/index.php/Guides:Thumb_Rotator

the approaches are quite different. The Thumb Rotator appears much cleaner and modular with its own name space and such...

My experiment is based on the kdp_js_api example:

http://dev.becausefoundation.org/films/onebridge/index-clips.php

And though I am using the readyF parameter to get a callback to JavaScript when the player is ready. I do not believe the function is being called and none of the callbacks are being attached.

var flashVars = {
        entryId: "wa5399nt92",
        readyF:"onKdpReady"
        };
       
swfobject.embedSWF("http://www.kaltura.com/kwidget/wid/_26954", "myKdp", "400", "360", "9.0.0", false, flashVars, params);

Does anyone see what I am doing wrong? Or have a pointer to a "best practices" example of controlling KDP from JavaScript?

Thanks,

Smallhands

Joined: 04/05/2009
Points: 5

If you want to access the player you must wait for it to be ready. This means that there should be a JS func on the page called 'onKdpReady' (according to your code). This function will be called by the player when it is ready.

Only after the player is ready you would be able to control it and get event & notifications.

BTW - looks like you are using an older version of the player (1.2.3). You might need a higher version in order to make this API work.

Joined: 05/06/2009
Points: 9

I collected the function, onKdpReady, and the rest of the player controlling functions into a single .js file that is included rather than directly in the PHP. From dropping into the debugger it appears to be at the correct lexical closure.

http://dev.becausefoundation.org/js/kaltura-player-controls.js

 function onKdpReady(playerId) {
         window.myKdp=get(playerId);
         get("Player_State").innerHTML="<br>&nbsp; READY (Id=" + playerId + ")";
         get("nowPlaying").innerHTML=(myKdp.evaluate('{entryId}'));
         getDuration();
         attachKdpEvents();
         addKdpListners();
 }

But, you really caught my attention at noting my use of an older version of the player..... I presume that you're speaking of the PHP.... I downloaded the PHP not too long ago (May 6th).... What is the current version and when did it come out?

Thanks!

Smallhands

Joined: 03/29/2009
Points: 764

Hi,

Current version is 2.0.12, it came out about 2 weeks ago.

Joined: 05/06/2009
Points: 9

So, concurrent with your reply I noted that it was the SWF that you were commenting on the version.

So, that brings up the issue of how a developer knows / specifies the SWF version intended?

Code insertion is being done by the SWFObject:

swfobject.embedSWF("http://www.kaltura.com/kwidget/wid/_26954", "myKdp", "640", "360", "9.0.0", false, flashVars, params);

But, nowhere that I see am I specifying a version. I had assumed that Kaltura.com/kwidget/... would always supply the "current release."

This could very well explain why I am not getting a call back from the SWF.

Thanks again!

Smallhands

Joined: 05/14/2009
Points: 69

I have the same problem. How can I use the new version of KDP?
Thanks.

Joined: 04/05/2009
Points: 5

There are 2 default widgets with version 2.0.2
48110 & 48111
one is dark one is light

http://www.kaltura.com/kwidget/wid/48110 OR 48111

for version 2.0.12 try
http://www.kaltura.com/kwidget/wid/0_1000239 or 0_1000240

Joined: 05/12/2010
Points: 28

I think this is pretty much the same question I've posed at Which KDP is this? - KDP has two versions with differing JS API interfaces, but there doesn't seem to be a documented means of identifying which KDP you're dealing with from JS. This seems wierd (and I expect it's just that I haven't found the right piece of docs yet).

Thanks Eitan for identifying those specific KDP IDs - but I ran into the same exact problem with some custom themed KDP on a client's Kaltura EE (or is it called Prem Edition now?) and it took us a couple of weeks to get a reply from Kaltura support.

He suggested some player.evaluate() code which should identify the KDP version ... but it didn't work on the KDP version we were using!

--
www.giantrobot.co.nzhttp://twitter.com/grobot

Joined: 05/12/2010
Points: 28

Found this after my post - from my quick test today this didn't work (I didn't have time allocated to dig further, but maybe it can point someone in the right direction)

I asked if there was a way to identify the KDP player version via JS (so as to use the appropriate API calls for that KDP version).

Nir replied,

2) There is no way to do it directly ... There is a workaround:
evaluate(“{configProxy.kuiConf.swfUrlVersion}”)

I tested this by obtaining my kdpPlayer object, then calling kdpPlayer.evaluate(“{configProxy.kuiConf.swfUrlVersion}”) but the result was 'null'. The same kdpPlayer object was working as expected for KDP JS API calls (v3 I think).

--
www.giantrobot.co.nzhttp://twitter.com/grobot