Popcorn.js Documentation

Popcorn Constructor

The Popcorn constructor allows the user to create Popcorn instances. An optional options object can be passed along to set properties for the new instance of Popcorn. The constructor can also be used to listen for DOMContentLoaded, executing a callback function when your page has finished loading.

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

Examples

The following code examples show the various ways a Popcorn instance can be created.

1
    Popcorn( "#video-element-id" );
1
2
3
    Popcorn( "#video-element-id", {
      frameAnimation: true
    });
1
2
3
4
5
6
7
    Popcorn( "#video-element-id", {
      defaults: {
        subtitle: {
          target: "subtitle-div"
        }
      }
    });
1
2
3
    Popcorn(function() {
      alert( "The page is loaded" );
    });
1
2
3
    Popcorn(function() {
      Popcorn( "#video-element-id" );
    });