Ready Overview
Knowing when wimpy has completed initializing or when a specific player is ready is an important part of working with some of the advanced features of Wimpy.
There are two "onReady" functions you can leverage:
1. At the player level (when a specific player is ready)
2. At
the global level (when wimpy has finished initializing)
Player onReady
This option is only available when establishing players via Javascript.
The way it works is that you first must establish a function that you want to be "pinged" when the palyer is ready, then you'll include a reference to that function in the "onReady" field in the options parameter as:
var someFunction = function(thePlayer){ } new wimpyPlayer({ onReady : someFunction, media : "foo.mp3" });
Or, you can leverage the onReady player function, which give you the ability to send in, and receive additional arguments as:
var someFunction = function(thePlayer, arg1, arg2){ thePlayer.setPlaylist("song1.mp3");
console.log(arg1, arg2); } var myPlayer = new wimpyPlayer();
myPlayer.onReady(someFunction, "foo", "bar");
More examples are available on the Javascript API > onReady page.
Global onReady
This option is useful for knowing when wimpy has finished setting up. There are a number of things that Wimpy does during setup such as:
- Load the Wimpy Player Icons (WimpyPlayerGlyphs font)
-
Configure defaults
- Test browser capabilities
- Search for and set up Players
- Search for and set up Buttons
- Initialize Players
- Initialize Buttons
It is **probably safe** to say that by the time the global wimpy.onReady is triggered, all of the buttons and players will be ready as well. We say **probably** because there may be some situations where a player may not be fully set up because it is loading a "heavy" skin, or a very large playlist.
However, you can still make use of the global wimpy functions when wimpy is ready, which you can use in conjunction with other API methods.
Use the global wimpy.onReady as follows:
var someFunction = function(arg1, arg2){ alert(arg1 + " : " arg2); }
wimpy.onReady(someFunction, "foo", "bar");
More examples are available on the Javascript API > wimpy.onReady page.
See Also
- Scope
- Overview (describes the "wimpy" object a little better)
- Global Wimpy Object Overview
- Player Handle, ID & Name
- Javascript API > onReady (player)
- Javascript API > wimpy.onReady (global)
- Player Options > onReady