From db2c86e1d71b5d3674452f9e6f28b2c35561d4d7 Mon Sep 17 00:00:00 2001 From: Karim Hamidou Date: Fri, 30 Sep 2011 17:05:08 +0200 Subject: [PATCH] initial commit of the js and example file --- .../mediafragment/popcorn.mediafragment.html | 44 ++++++++++++++++ .../mediafragment/popcorn.mediafragment.js | 52 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 plugins/mediafragment/popcorn.mediafragment.html create mode 100644 plugins/mediafragment/popcorn.mediafragment.js diff --git a/plugins/mediafragment/popcorn.mediafragment.html b/plugins/mediafragment/popcorn.mediafragment.html new file mode 100644 index 0000000..33a1da8 --- /dev/null +++ b/plugins/mediafragment/popcorn.mediafragment.html @@ -0,0 +1,44 @@ + + + + Popcorn footnote Plug-in Demo + + + + + + +

Popcorn Mediafragment Plug-in Demo

+

Clicking the pause button should update the location hash.

+

Copypasting the changed url in a browser bar should take you to the exact instant in the video.

+
+ +
+ + + diff --git a/plugins/mediafragment/popcorn.mediafragment.js b/plugins/mediafragment/popcorn.mediafragment.js new file mode 100644 index 0000000..0f01e63 --- /dev/null +++ b/plugins/mediafragment/popcorn.mediafragment.js @@ -0,0 +1,52 @@ +// 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 ); -- 2.43.0