--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Popcorn footnote Plug-in Demo</title>
+
+ <script src="../../popcorn.js"></script>
+ <script src="popcorn.mediafragment.js"></script>
+ <script>
+ document.addEventListener('DOMContentLoaded', function () {
+ var p = Popcorn( "#video" ).mediafragment({start: 0}).play()
+
+ document.getElementById("pauseButton").addEventListener( 'click', function() {
+ p.pause()
+ });
+
+ }, false);
+
+ </script>
+</head>
+<body>
+ <h1 id="qunit-header">Popcorn Mediafragment Plug-in Demo</h1>
+ <p> Clicking the pause button should update the location hash.</p>
+ <p> Copypasting the changed url in a browser bar should take you to the exact instant in the video.</p>
+ <div>
+ <video id="video"
+ controls preload="none"
+ width="250px"
+ poster="../../test/poster.png">
+
+ <source id="mp4"
+ src="../../test/trailer.mp4"
+ type='video/mp4; codecs="avc1, mp4a"'>
+
+ <source id="ogv"
+ src="../../test/trailer.ogv"
+ type='video/ogg; codecs="theora, vorbis"'>
+
+ <p>Your user agent does not support the HTML5 Video element.</p>
+
+ </video>
+ </div>
+ <button id="pauseButton">Pause</button>
+</body>
+</html>
--- /dev/null
+// PLUGIN: Mediafragment
+
+(function ( Popcorn ) {
+
+ /**
+ * Mediafragment popcorn plug-in
+ * Adds (limited) support for mediafragment requests
+ * to a popcorn video.
+ * @param {Object} options
+ *
+ **/
+ Popcorn.plugin( "mediafragment" , {
+
+ manifest: {
+ about: {
+ name: "Popcorn mediafragment plugin",
+ version: "0.1",
+ author: "Karim Hamidou",
+ website: "http://neyret.fr/~karim"
+ },
+ options: {
+ }
+ },
+
+ _setup: function( options ) {
+ var advanceTime = function() {
+ var url = window.location.href;
+
+ if ( url.split("#")[1] != null ) {
+ pageoffset = url.split( "#" )[1];
+
+ if ( pageoffset.substring( 2 ) != null ) {
+ var offsettime = pageoffset.substring( 2 );
+ this.currentTime(parseFloat(offsettime));
+ }
+ }
+ }
+
+
+ this.listen( 'loadedmetadata', advanceTime );
+ this.listen("pause", function(data) {
+ splitArr = window.location.href.split("#")
+ history.replaceState({}, "", splitArr[0] + "#t=" + this.currentTime().toFixed(2));
+ });
+
+ },
+
+ _teardown: function( options ) {
+ // FIXME: anything to implement here ?
+ }
+ });
+})( Popcorn );