Skip to content
giannif edited this page Dec 16, 2014 · 6 revisions

jQuery/Zepto support

This is a style preference, but does offer the advantage of not having a global "player" variable. However, there are a lot of ways you can structure your app so you don't have a global player(s) variable.

Main benefit:

  • Use jQuery style event handlers and method invocations.
Events

Events work similar to hooking into a PJS.Player instance. Except you bind like so:

// you bind off the jQuery-wrapped placeholder element.
$(".pjs").bind("pjs:ready", callback);

Also, your callback will be different. It will be a jQuery callback: the first argument will be the jQuery event, and the second will be the PJS.Player events object.

Methods

Methods can be triggered by calling trigger on a jQuery collection.

// you trigger off the jQuery-wrapped placeholder element.
$(".pjs").trigger("pjs:pause");
$(".pjs").trigger("pjs:playIndex",[1,10]); // Pass arguments as an array.
Clone this wiki locally