JW Player: ActionScript API Calls
JW Player 5 supports an extremely flexible API for plugins, that can be built in actionscript). It is possible to read the config/playlist variables of the player, call player functions, and listen for Flash Events. A small initialization routine is needed to connect your apps to the player.
Version 5 also supports plugins and javascript for version 4 of the player, although some features may no longer be available.
Initialization
Javascript
Please note that the player will NOT be available the instant your HTML page is loaded and the first javascript is executed; the SWF file (~70k) needs to be loaded and instantiated first. You can avoid this issue by defining a simple javascript function, and configuring the player to call it using the playerready flashvar. When the player has succesfully instantiated, it will call the javascript function you specify in the flashvar. The object this callback passes will contain the id, version and client of the player, which allows you to subscribe to events and call player functions, etc. Use the id variable to get a reference to the player itself. Example:
// "playerready" flashvar was set to "playerReadyCallback"
var player;
function playerReadyCallback(obj) {
alert('the videoplayer '+obj['id']+' has been instantiated');
player = document.getElementById(obj['id']);
};
If you are not interested in calling the player when the page is loading, you won't need this function. You can then simply use the ID of the embed/object tag that embeds the player to get a reference. A simple getElementById() function will do the trick, so it can be called. This function needs the ID of the object/embed tag as a reference. So for example with this embed tag:
You can get a pointer to the player with this line of code:
var player = document.getElementById('myplayer');
Note you must add both the id and name attributes in the