<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.addEventListener( "DOMContentLoaded", function () {
+ var p = Popcorn( "#video" )
+ .mediafragment({start: 0})
+ .play();
- document.getElementById("pauseButton").addEventListener( 'click', function() {
- p.pause()
- });
+ document.getElementById("pauseButton").addEventListener( "click", function() {
+ p.pause()
+ });
}, false);
/**
* Mediafragment popcorn plug-in
- * Adds (limited) support for mediafragment requests
- * to a popcorn video.
+ * Adds (limited) support for mediafragment requests
+ * to a popcorn video.
* @param {Object} options
*
**/
options: {
}
},
-
+
_setup: function( options ) {
var advanceTime = function() {
var url = window.location.href;
-
- if ( url.split("#")[1] != null ) {
- pageoffset = url.split( "#" )[1];
-
+
+ if ( url.split( "#" )[ 1 ] != null ) {
+ pageoffset = url.split( "#" )[1];
+
if ( pageoffset.substring( 2 ) != null ) {
- var offsettime = pageoffset.substring( 2 );
- this.currentTime(parseFloat(offsettime));
- }
+ var offsettime = pageoffset.substring( 2 );
+ this.currentTime( parseFloat( offsettime ) );
+ }
}
}
-
+
var updateTime = function() {
- splitArr = window.location.href.split("#")
- history.replaceState({}, "", splitArr[0] + "#t=" + this.currentTime().toFixed(2));
+ splitArr = window.location.href.split( "#" )
+ history.replaceState( {}, "", splitArr[0] + "#t=" + this.currentTime().toFixed( 2 ) );
};
-
- this.listen( 'loadedmetadata', advanceTime );
- this.listen("pause", updateTime);
- this.listen("seeked", updateTime);
-
+
+ this.listen( "loadedmetadata", advanceTime );
+ this.listen( "pause", updateTime );
+ this.listen( "seeked", updateTime );
},
_teardown: function( options ) {
<source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
-
+
<source id='webm'
src="../../test/trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>
var popped = Popcorn( "#video" ),
expects = 4,
- count = 0;
+ count = 0;
expect( expects );
ok( "mediafragment" in popped, "mediafragment is a method of the popped instance" );
plus();
- var currstate = window.location.href.split("#t=");
+ var currstate = window.location.href.split( "#t=" );
equals( currstate[1], undefined, "initially, there is no # in the url" );
plus();
popped.mediafragment({
- start: 0,
+ start: 0,
});
popped.exec( 2, function() {
popped.pause();
popped.play();
-
-
});
popped.exec( 3, function() {
- var currstate = window.location.href.split("#t=");
- var time = + currstate[1];
-
+ var currstate = window.location.href.split( "#t=" );
+ var time = + currstate[ 1 ];
+
// popcorn's precision is limited to the second.
ok(time >= 2 && time <= 3, "correct time is set" );
plus();
popped.play();
-
+
popped.currentTime(5);
});
- popped.exec( 6, function() {
- var currstate = window.location.href.split("#t=");
- var time = + currstate[1];
+ popped.exec( 6, function() {
+ var currstate = window.location.href.split( "#t=" );
+ var time = + currstate[ 1 ];
console.log(time);
// popcorn's precision is limited to the second.
ok(time >= 5 && time <= 6, "correct time is set after seeking" );
- plus();
-
+ plus();
+
});
-
+
popped.exec( 10, function() {
// clear the address bar
- window.location.href = window.location.href.split("#t=")[0];
+ window.location.href = window.location.href.split( "#t=" )[ 0 ];
});
-
+
popped.play();
});
\ No newline at end of file