Popcorn( callback | id, optionsObject )
Purpose
Creates and returns a new Popcorn instance.
All Popcorn media methods, plugins and callbacks are chained directly from a Popcorn instance. The context will always be the instance itself.
Options
- id - The id of the media element
- callback - A function to execute when the DOM is ready.
- optionsObject - An object to specify additional options for the popcorn instance. For example frameAnimation, frameRate, and plugin defaults.
Examples
The following code examples show the various ways a Popcorn instance can be created.
1 Popcorn( "#video-element-id" );
1 Popcorn( "#video-element-id", {
2 frameAnimation: true
3 });
1 Popcorn( "#video-element-id", {
2 defaults: {
3 subtitle: {
4 target: "subtitle-div"
5 }
6 }
7 });
1 Popcorn(function() {
2 alert( "The page is loaded" );
3 });
1 Popcorn(function() {
2 Popcorn( "#video-element-id" );
3 });
- Live demo showing how to create a Popcorn instance
- Live demo showing the context within various media methods, as well has how to create an instance
- Live demo showing the context within a plugin
- Live demo using Popcorn to call a function when the DOM is ready