Popcorn Context

by Fobos Deimos

HTML

<script src="http://popcornjs.org/code/dist/popcorn-complete.min.js"></script>
<video height="180" width="300" id="video" controls> 
<source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.mp4"></source>
<source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.ogv"></source>
<source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.webm"></source>
</video>

CSS

html{font-family:arial;}

JavaScript

(function(Popcorn) {
    
  Popcorn.plugin( "funzo" , function( options ) {

    return {

      start: function( event, options ) {

        // Inside of these plugin method definitions, you can 
        // always trust that the context will be the Popcorn 
        // instance that will call the plugin method...

        this.pause();

        // ...would pause the current video when the plugin 
        // is executed.

      },
      end: function( event, options ) {

        // still the same context in here!

      }
    };
  });
    
})(Popcorn);

// "$pop" is a Popcorn instance
var $pop = Popcorn("#video");

// "funzo" is an instance method!
$pop.funzo({
    start: 2, 
    end: 0
});