Popcorn Example

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 src="http://videos.mozilla.org/serv/webmademovies/popcornplug.ogv">
<source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.webm">
</video>

CSS

html{font-family:arial;}

JavaScript

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

// "exec" is an instance method
$pop.exec( 2, function() {
   
    // Inside this callback, the "context" is always
    // the Popcorn instance. 
    // Currently, "$pop" is the context, which means...

    this.play();

    // we can refer to the current context via `this`, 
    // which will always refer to the Popcorn instance
    
    // Popcorn instance methods that return the instance 
    // can be chained:
    this.currentTime( 4 ).play();
   
});