diff -r ff11367d4955 -r e9400c80e1e4 web/res/metadataplayer/Mediafragment.js --- a/web/res/metadataplayer/Mediafragment.js Mon Oct 15 14:34:47 2012 +0200 +++ b/web/res/metadataplayer/Mediafragment.js Tue Oct 02 14:40:14 2012 +0200 @@ -10,16 +10,22 @@ } }) }; - this.bindPopcorn("pause","setHashToTime"); - this.bindPopcorn("seeked","setHashToTime"); - this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation"); + this.onMdpEvent("Mediafragment.setHashToAnnotation","setHashToAnnotation"); this.blocked = false; } IriSP.Widgets.Mediafragment.prototype = new IriSP.Widgets.Widget(); IriSP.Widgets.Mediafragment.prototype.draw = function() { + this.onMediaEvent("pause","setHashToTime"); + this.onMediaEvent("seeked","setHashToTime"); this.goToHash(); + var _this = this; + this.getWidgetAnnotations().forEach(function(_annotation) { + _annotation.on("click", function() { + _this.setHashToAnnotation(_annotation.id); + }) + }) } IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) { @@ -52,11 +58,11 @@ if (this.last_hash_key == "id") { var _annotation = this.source.getElement(this.last_hash_value); if (typeof _annotation !== "undefined") { - this.player.popcorn.currentTime(_annotation.begin.getSeconds()); + this.media.setCurrentTime(_annotation.begin); } } if (this.last_hash_key == "t") { - this.player.popcorn.currentTime(this.last_hash_value); + this.media.setCurrentTime(1000*this.last_hash_value); } break; } @@ -68,10 +74,8 @@ this.setHash( 'id', _annotationId ); } -IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) { - if (_time !== NaN) { - this.setHash( 't', this.player.popcorn.currentTime() ); - } +IriSP.Widgets.Mediafragment.prototype.setHashToTime = function() { + this.setHash( 't', this.media.getCurrentTime().getSeconds() ); } IriSP.Widgets.Mediafragment.prototype.setHash = function(_key, _value) { @@ -100,5 +104,5 @@ window.clearTimeout(this.blockTimeout); } this.blocked = true; - this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1000); + this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1500); }