# HG changeset patch # User veltr # Date 1348034631 -32400 # Node ID 18dfa62b411a4162867aa8bafe421ee3e4f8fd63 # Parent 45e655657f7adc52e0ea35e225192e792e39990f Update of the Metadataplayer diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Wed Sep 19 15:03:51 2012 +0900 @@ -18,94 +18,90 @@ url: '{{ json_url }}', format: 'ldt' }; -var _config = { - gui: { - width: '{{ player_width }}', - container: '{{ player_id }}_embed', - css: '{{WEB_URL}}{{LDT_MEDIA_PREFIX}}metadataplayer/LdtPlayer-core.css', - default_options: { - metadata: _metadata +var _config = { + width: '{{ player_width }}', + container: '{{ player_id }}_embed', + css: '{{WEB_URL}}{{LDT_MEDIA_PREFIX}}metadataplayer/LdtPlayer-core.css', + default_options: { + metadata: _metadata + }, + widgets: [ + { + {% if external_url %} + type: "AutoPlayer", + video: "{{ external_url }}", + {% else %} + type: "JwpPlayer", + streamer: function(_url) { + var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//); + if (_matches) { + return _matches[0]; + } else { + return _url; + } + }, + live: true, + provider: "rtmp", + {% endif %} + height: 300, + autostart: true }, - widgets: [ - { - type: "Polemic" - },{ - type: "Sparkline" - },{ - type: "Slider" - },{ - type: "AnnotationsList", - container: "AnnotationsList_ext", - ajax_url: "{% url segment_api_empty %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}", - ajax_granularity : 300000, - default_thumbnail : "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/imgs/video_sequence.png" - },{ - type: "Controller" - },{ - type: "Segments", - annotation_type: ["chap","découpage"] - },{ - type: "Slice", - start_visible : false, - live_update : true - },{ - type: "Arrow", - base_height: 3 - },{ - type: "Annotation", - start_minimized: true, - site_name : "Lignes de Temps", - annotation_type: ["chap","découpage"] - },{ - type: "Tweet", - hide_timeout: 5000 - },{ - type: "CreateAnnotation", - api_endpoint_template: "{% url annotation_api_empty %}{% templatetag openvariable %}id{% templatetag closevariable %}.json", - api_method: "PUT", - after_send_timeout: 8000, - close_after_send: false, - tag_titles: ["#amateur", "#digital-humanities"], - creator_name: '{{request.user.username}}', - creator_avatar: '{% thumbnail request.user.get_profile.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png" - },{ - type: "Slideshare", - container: "Slideshare_ext", - embed_width: 400, - embed_height: 334, - annotation_type: "slide" - },{ - type: "Mediafragment" - },{ - type: "Social", - container: "Social_ext", - url: document.location.href.replace(/#.*$/,""), - text: document.title - } - ] - }, - player: { - {% if external_url %} - video: '{{ external_url }}', - type: 'auto', - {% else %} - streamer: function(_url) { - var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//); - if (_matches) { - return _matches[0]; - } else { - return _url; - } - }, - type: 'jwplayer', - live: true, - provider: "rtmp", - {% endif %} - height: 300, - width: '{{ player_width }}', - autostart: true, - metadata: _metadata - } + { + type: "Polemic" + },{ + type: "Sparkline" + },{ + type: "Slider" + },{ + type: "AnnotationsList", + container: "AnnotationsList_ext", + ajax_url: "{% url segment_api_empty %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}", + ajax_granularity : 300000, + default_thumbnail : "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/imgs/video_sequence.png" + },{ + type: "Controller" + },{ + type: "Segments", + annotation_type: ["chap","découpage"] + },{ + type: "Slice", + start_visible : false, + live_update : true + },{ + type: "Arrow", + base_height: 3 + },{ + type: "Annotation", + start_minimized: true, + site_name : "Lignes de Temps", + annotation_type: ["chap","découpage"] + },{ + type: "Tweet", + hide_timeout: 5000 + },{ + type: "CreateAnnotation", + api_endpoint_template: "{% url annotation_api_empty %}{% templatetag openvariable %}id{% templatetag closevariable %}.json", + api_method: "PUT", + after_send_timeout: 8000, + close_after_send: false, + tag_titles: ["#amateur", "#digital-humanities"], + creator_name: '{{request.user.username}}', + creator_avatar: '{% thumbnail request.user.get_profile.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png" + },{ + type: "Slideshare", + container: "Slideshare_ext", + embed_width: 400, + embed_height: 334, + annotation_type: "slide" + },{ + type: "Mediafragment" + },{ + type: "Social", + container: "Social_ext", + url: document.location.href.replace(/#.*$/,""), + text: document.title + } + ] }; _myPlayer = new IriSP.Metadataplayer(_config); diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/Annotation.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Wed Sep 19 15:03:51 2012 +0900 @@ -50,38 +50,37 @@ IriSP.Widgets.Annotation.prototype.draw = function() { this.renderTemplate(); - this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), "socialWidget", { type: "Social" }); - this.bindPopcorn("timeupdate","onTimeupdate"); - this.bindPopcorn("IriSP.Annotation.hide","hide"); - this.bindPopcorn("IriSP.Annotation.show","show"); - this.bindPopcorn("IriSP.Annotation.minimize","minimize"); - this.bindPopcorn("IriSP.Annotation.maximize","maximize"); - this.bindPopcorn("IriSP.Annotation.getBounds","sendBounds"); + this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); + this.onMediaEvent("timeupdate","onTimeupdate"); + this.onMdpEvent("Annotation.hide","hide"); + this.onMdpEvent("Annotation.show","show"); + this.onMdpEvent("Annotation.minimize","minimize"); + this.onMdpEvent("Annotation.maximize","maximize"); + this.onMdpEvent("Annotation.getBounds","sendBounds"); this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); this.onTimeupdate(); } -IriSP.Widgets.Annotation.prototype.onTimeupdate = function() { - var _time = Math.floor(this.player.popcorn.currentTime() * 1000), - _list = this.getWidgetAnnotationsAtTime(); +IriSP.Widgets.Annotation.prototype.onTimeupdate = function(_time) { + var _list = this.getWidgetAnnotationsAtTime(); if (_list.length) { if (_list[0].id !== this.lastAnnotation) { this.drawAnnotation(_list[0]); this.bounds = [ _list[0].begin.valueOf(), _list[0].end.valueOf() ]; } - this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2}); + this.player.trigger("Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2}); } else { this.lastAnnotation = false; this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); - this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time}); + this.player.trigger("Arrow.updatePosition",{widget: this.type, time: _time}); this.bounds = [ _time, _time ]; } this.sendBounds(); } IriSP.Widgets.Annotation.prototype.sendBounds = function() { - this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",this.bounds); + this.player.trigger("Annotation.boundsChanged",this.bounds); } IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { @@ -107,7 +106,7 @@ }); this.$.find('.Ldt-Annotation-TagLabel').click(function() { - _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); + _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); }); } else { this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Wed Sep 19 15:03:51 2012 +0900 @@ -6,7 +6,6 @@ this.throttledRefresh = IriSP._.throttle(function() { _this.refresh(false); }, 1500); - this.mashupMode = (this.source.currentMedia.elementType === "mashup"); }; IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); @@ -79,9 +78,9 @@ var _n = this.refresh(true); if (this.searchString) { if (_n) { - this.player.popcorn.trigger("IriSP.search.matchFound"); + this.player.trigger("search.matchFound"); } else { - this.player.popcorn.trigger("IriSP.search.noMatchFound"); + this.player.trigger("search.noMatchFound"); } } } @@ -89,13 +88,9 @@ //obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id; IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() { - var _currentTime = this.player.popcorn.currentTime(), - _duration = this.source.getDuration(); - if (typeof _currentTime == "undefined") { - _currentTime = 0; - } + var _currentTime = this.media.getCurrentTime(), + _duration = this.media.duration; this.lastAjaxQuery = _currentTime; - _currentTime = Math.floor(1000 * _currentTime); var _url = Mustache.to_html(this.ajax_url, { media : this.source.currentMedia.id, begin : Math.max(0, _currentTime - this.ajax_granularity), @@ -107,11 +102,8 @@ } IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { - var _currentTime = this.player.popcorn.currentTime(); - if (typeof _currentTime == "undefined") { - _currentTime = 0; - } - var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + var _currentTime = this.media.getCurrentTime(); + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) { this.lastMashupAnnotation = _currentAnnotation.id; var _currentMedia = _currentAnnotation.getMedia(), @@ -132,13 +124,10 @@ return 0; } var _this = this, - _currentTime = this.player.popcorn.currentTime(); - if (typeof _currentTime == "undefined") { - _currentTime = 0; - } + _currentTime = this.media.getCurrentTime(); var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); if (this.mashupMode) { - var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); if (typeof _currentAnnotation !== "undefined") { _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds(); var _mediaId = _currentAnnotation.getMedia().id; @@ -246,7 +235,7 @@ }); this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { - _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); + _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); }) if(this.searchString) { @@ -262,7 +251,7 @@ if (this.mashupMode) { this.ajaxMashup(); } else { - if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { + if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) { this.ajaxSource(); } } @@ -272,14 +261,16 @@ IriSP.Widgets.AnnotationsList.prototype.draw = function() { + this.mashupMode = (this.media.elementType === "mashup"); + this.renderTemplate(); this.list_$ = this.$.find(".Ldt-AnnotationsList-ul"); - this.bindPopcorn("IriSP.search", "onSearch"); - this.bindPopcorn("IriSP.search.closed", "onSearch"); - this.bindPopcorn("IriSP.search.cleared", "onSearch"); - this.bindPopcorn("IriSP.AnnotationsList.refresh","refresh"); + this.onMdpEvent("search", "onSearch"); + this.onMdpEvent("search.closed", "onSearch"); + this.onMdpEvent("search.cleared", "onSearch"); + this.onMdpEvent("AnnotationsList.refresh","refresh"); var _this = this; @@ -299,14 +290,14 @@ }, this.refresh_interval); } + this.onMdpEvent("createAnnotationWidget.addedAnnotation"); var _events = [ - "IriSP.createAnnotationWidget.addedAnnotation", "timeupdate", "seeked", "loadedmetadata" ]; for (var _i = 0; _i < _events.length; _i++) { - this.player.popcorn.listen(_events[_i], this.throttledRefresh); + this.onMediaEvent(_events[_i], this.throttledRefresh); } this.throttledRefresh(); diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/Arrow.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Arrow.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Arrow.js Wed Sep 19 15:03:51 2012 +0900 @@ -33,9 +33,9 @@ fill: this.fill_url ? ( 'url(' + this.fill_url + ')' ) : this.fill_color }); this.moveTo(0); - this.bindPopcorn("IriSP.Arrow.updatePosition","onUpdatePosition"); - this.bindPopcorn("IriSP.Arrow.takeover","onTakeover"); - this.bindPopcorn("IriSP.Arrow.release","onRelease"); + this.onMdpEvent("Arrow.updatePosition","onUpdatePosition"); + this.onMdpEvent("Arrow.takeover","onTakeover"); + this.onMdpEvent("Arrow.release","onRelease"); } IriSP.Widgets.Arrow.prototype.drawAt = function(_x) { diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/AutoPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AutoPlayer.js Wed Sep 19 15:03:51 2012 +0900 @@ -0,0 +1,57 @@ +IriSP.Widgets.AutoPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.AutoPlayer.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.AutoPlayer.prototype.defaults = { + default_type: "JwpPlayer" +} + +IriSP.Widgets.AutoPlayer.prototype.draw = function() { + + if (typeof this.video === "undefined") { + this.video = this.media.video; + } + + var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ], + _opts = {}, + _types = [ + { + regexp: /\.(ogg|ogv|webm)$/, + type: "PopcornPlayer" + }, + { + regexp: /^(https?:\/\/)?(www\.)?youtube\.com/, + type: "PopcornPlayer" + }, + { + regexp: /^(https?:\/\/)?(www\.)?vimeo\.com/, + type: "PopcornPlayer" + }, + { + regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/, + type: "DailymotionPlayer" + } + ]; + + for (var i = 0; i < _types.length; i++) { + if (_types[i].regexp.test(this.video)) { + _opts.type = _types[i].type + } + } + + if (typeof _opts.type === "undefined") { + _opts.type = this.default_type + } + + for (var i = 0; i < _props.length; i++) { + if (typeof this[_props[i]] !== "undefined") { + _opts[_props[i]] = this[_props[i]]; + } + } + + + this.insertSubwidget(this.$, _opts); + +} \ No newline at end of file diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/Controller.css --- a/src/ldt/ldt/static/ldt/metadataplayer/Controller.css Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Controller.css Wed Sep 19 15:03:51 2012 +0900 @@ -9,7 +9,7 @@ } .Ldt-Ctrl-Left { - float:left; + float:left; width: 300px; } .Ldt-Ctrl-Right { @@ -82,13 +82,12 @@ } .Ldt-Ctrl-Search { - display: none; - width: 165px; - height: 25px; - border: 1px; - border-color: #CFCFCF; - float: left; - text-align: center; + width: 0; float: left; overflow: hidden; +} + +input.Ldt-Ctrl-SearchInput { + width: 145px; height: 13px; margin: 2px; padding: 3px; + border: 1px solid #8080a0; border-radius: 3px; font-size: 13px; } .Ldt-Ctrl-Time { diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/Controller.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Wed Sep 19 15:03:51 2012 +0900 @@ -1,16 +1,16 @@ /* Displays Play and Pause buttons, Search Button and Form, Volume Control */ IriSP.Widgets.Controller = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); - - this._searchLastValue = ""; + IriSP.Widgets.Widget.call(this, player, config); + this.lastSearchValue = ""; }; IriSP.Widgets.Controller.prototype = new IriSP.Widgets.Widget(); IriSP.Widgets.Controller.prototype.defaults = { disable_annotate_btn: false, - disable_search_btn: false + disable_search_btn: false, + disable_ctrl_f: false } IriSP.Widgets.Controller.prototype.template = @@ -87,25 +87,25 @@ this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar"); // handle events - this.bindPopcorn("play","playButtonUpdater"); - this.bindPopcorn("pause","playButtonUpdater"); - this.bindPopcorn("volumechange","volumeUpdater"); - this.bindPopcorn("timeupdate","timeDisplayUpdater"); - this.bindPopcorn("loadedmetadata","timeDisplayUpdater"); - this.bindPopcorn("loadedmetadata","volumeUpdater"); - this.bindPopcorn("IriSP.search.matchFound","searchMatch"); - this.bindPopcorn("IriSP.search.noMatchFound","searchNoMatch"); - this.bindPopcorn("IriSP.search.triggeredSearch","triggeredSearch"); + this.onMediaEvent("play","playButtonUpdater"); + this.onMediaEvent("pause","playButtonUpdater"); + this.onMediaEvent("volumechange","volumeUpdater"); + this.onMediaEvent("timeupdate","timeDisplayUpdater"); + this.onMediaEvent("loadedmetadata","volumeUpdater"); + this.onMdpEvent("search.matchFound","searchMatch"); + this.onMdpEvent("search.noMatchFound","searchNoMatch"); + this.onMdpEvent("search.triggeredSearch","triggeredSearch"); + this.onMdpEvent("search.cleared","hideSearchBlock"); // handle clicks this.$playButton.click(this.functionWrapper("playHandler")); this.$.find(".Ldt-Ctrl-Annotate").click(function() { - _this.player.popcorn.trigger("IriSP.CreateAnnotation.toggle"); + _this.player.trigger("CreateAnnotation.toggle"); }); this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); - this.$searchInput.keyup(this.functionWrapper("searchHandler") ); + this.$searchInput.keyup(this.functionWrapper("searchHandler")); var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control"); this.$.find('.Ldt-Ctrl-Sound') @@ -121,13 +121,28 @@ }).mouseout(function() { _volctrl.hide(); }); - + + // Handle CTRL-F + if (!this.disable_ctrl_f) { + var _fKey = "F".charCodeAt(0), + _lastCtrlFTime = 0; + IriSP.jQuery(document).keydown(function(_event) { + if (_event.keyCode === _fKey && (_event.ctrlKey || _event.metaKey)) { + var _time = IriSP.jQuery.now(); + if (_time - _lastCtrlFTime > 2000) { + _this.searchButtonHandler(); + } + _lastCtrlFTime = _time; + return false; + } + }); + } // Allow Volume Cursor Dragging this.$volumeBar.slider({ slide: function(event, ui) { _this.$volumeBar.attr("title",_this.l10n.volume+': ' + ui.value + '%'); - _this.player.popcorn.volume(ui.value / 100); + _this.media.setVolume(ui.value / 100); }, stop: this.functionWrapper("volumeUpdater") }); @@ -135,33 +150,26 @@ // trigger an IriSP.Player.MouseOver to the widgets that are interested (i.e : sliderWidget) this.$.hover( function() { - _this.player.popcorn.trigger("IriSP.Player.MouseOver"); + _this.player.trigger("Player.MouseOver"); }, function() { - _this.player.popcorn.trigger("IriSP.Player.MouseOut"); + _this.player.trigger("Player.MouseOut"); }); + + this.timeDisplayUpdater(new IriSP.Model.Time(0)); /* some players - including jwplayer - save the state of the mute button between sessions */ - + //TODO: MOVE TO THE PLAYER/ window.setTimeout(this.functionWrapper("volumeUpdater"), 1000); }; /* Update the elasped time div */ -IriSP.Widgets.Controller.prototype.timeDisplayUpdater = function() { - var _curTime = this.player.popcorn.roundTime(); - if (typeof this._previousSecond !== "undefined" && _curTime === this._previousSecond) { - return; - } +IriSP.Widgets.Controller.prototype.timeDisplayUpdater = function(_time) { // we get it at each call because it may change. - var _totalTime = this.source.getDuration(), - _elapsedTime = new IriSP.Model.Time(); - - _elapsedTime.setSeconds(_curTime); - - this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_elapsedTime.toString()); + var _totalTime = this.media.duration; + this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_time.toString()); this.$.find(".Ldt-Ctrl-Time-Total").html(_totalTime.toString()); - this._previousSecond = _curTime; }; /* update the icon of the button - separate function from playHandler @@ -169,10 +177,7 @@ the jwplayer window) we have to change the icon without playing/pausing */ IriSP.Widgets.Controller.prototype.playButtonUpdater = function() { - - var status = this.player.popcorn.media.paused; - - if (status) { + if (this.media.getPaused()) { /* the background sprite is changed by adding/removing the correct classes */ this.$playButton .attr("title", this.l10n.play) @@ -188,23 +193,24 @@ IriSP.Widgets.Controller.prototype.playHandler = function() { - - var status = this.player.popcorn.media.paused; - - if (status) { - this.player.popcorn.play(); + if (this.media.getPaused()) { + this.media.play(); } else { - this.player.popcorn.pause(); + this.media.pause(); } }; IriSP.Widgets.Controller.prototype.muteHandler = function() { - this.player.popcorn.muted(!this.player.popcorn.muted()); + if (this.media.getMuted()) { + this.media.unmute(); + } else { + this.media.mute(); + } }; IriSP.Widgets.Controller.prototype.volumeUpdater = function() { - var _muted = this.player.popcorn.muted(), - _vol = this.player.popcorn.volume(); + var _muted = this.media.getMuted(), + _vol = this.media.getVolume(); if (_vol === false) { _vol = .5; } @@ -221,7 +227,7 @@ }; IriSP.Widgets.Controller.prototype.showSearchBlock = function() { - this.$searchBlock.show("blind", { direction: "horizontal"}, 100); + this.$searchBlock.animate({ width:"160px" }, 200); this.$searchInput.css('background-color','#fff'); this.$searchInput.focus(); @@ -233,25 +239,23 @@ this._positiveMatch = false; // tell the world the field is open - this.player.popcorn.trigger("IriSP.search.open"); + this.player.trigger("search.open"); }; IriSP.Widgets.Controller.prototype.hideSearchBlock = function() { - this._searchLastValue = this.$searchInput.val(); - this.$searchInput.val(''); - this.$searchBlock.hide("blind", { direction: "horizontal"}, 75); - + this.$searchBlock.animate( { width: 0 }, 200); this._positiveMatch = false; - - this.player.popcorn.trigger("IriSP.search.closed"); + this.player.trigger("search.closed"); }; /** react to clicks on the search button */ IriSP.Widgets.Controller.prototype.searchButtonHandler = function() { - if ( this.$searchBlock.is(":hidden") ) { + if ( !this.$searchBlock.width() ) { this.showSearchBlock(); - this.$searchInput.val(this._searchLastValue); - this.player.popcorn.trigger("IriSP.search", this._searchLastValue); // trigger the search to make it more natural. + var _val = this.$searchInput.val(); + if (_val) { + this.player.trigger("search", _val); // trigger the search to make it more natural. + } } else { this.hideSearchBlock(); } @@ -260,16 +264,23 @@ /** this handler is called whenever the content of the search field changes */ IriSP.Widgets.Controller.prototype.searchHandler = function() { - this._searchLastValue = this.$searchInput.val(); + if ( !this.$searchBlock.width() ) { + this.$searchBlock.css({ width:"160px" }); + this.$searchInput.css('background-color','#fff'); + } + var _val = this.$searchInput.val(); this._positiveMatch = false; - + // do nothing if the search field is empty, instead of highlighting everything. - if (this._searchLastValue == "") { - this.player.popcorn.trigger("IriSP.search.cleared"); - this.$searchInput.css('background-color',''); - } else { - this.player.popcorn.trigger("IriSP.search", this._searchLastValue); + if (_val !== this.lastSearchValue) { + if (_val) { + this.player.trigger("search", _val); + } else { + this.player.trigger("search.cleared"); + this.$searchInput.css('background-color',''); + } } + this.lastSearchValue = _val; }; /** @@ -293,7 +304,7 @@ IriSP.Widgets.Controller.prototype.triggeredSearch = function(searchString) { this.showSearchBlock(); this.$searchInput.attr('value', searchString); - this.player.popcorn.trigger("IriSP.search", searchString); // trigger the search to make it more natural. + this.player.trigger("search", searchString); // trigger the search to make it more natural. }; diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js --- a/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js Wed Sep 19 15:03:51 2012 +0900 @@ -163,8 +163,8 @@ this.hide(); } - this.bindPopcorn("IriSP.CreateAnnotation.toggle","toggle"); - this.bindPopcorn("IriSP.Slice.boundsChanged","onBoundsChanged"); + this.onMdpEvent("CreateAnnotation.toggle","toggle"); + this.onMdpEvent("Slice.boundsChanged","onBoundsChanged"); this.begin = new IriSP.Model.Time(); this.end = this.source.getDuration(); this.$.find("form").submit(this.functionWrapper("onSubmit")); @@ -188,9 +188,9 @@ this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected"); this.$.slideDown(); if (this.minimize_annotation_widget) { - this.player.popcorn.trigger("IriSP.Annotation.minimize"); + this.player.trigger("Annotation.minimize"); } - this.player.popcorn.trigger("IriSP.Slice.show"); + this.player.trigger("Slice.show"); } IriSP.Widgets.CreateAnnotation.prototype.hide = function() { @@ -198,9 +198,9 @@ this.visible = false; this.$.slideUp(); if (this.minimize_annotation_widget) { - this.player.popcorn.trigger("IriSP.Annotation.maximize"); + this.player.trigger("Annotation.maximize"); } - this.player.popcorn.trigger("IriSP.Slice.hide"); + this.player.trigger("Slice.hide"); } } @@ -234,8 +234,8 @@ } IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() { - if (this.pause_on_write && !this.player.popcorn.media.paused) { - this.player.popcorn.pause(); + if (this.pause_on_write && !this.media.getPaused()) { + this.media.pause(); } } @@ -344,10 +344,10 @@ _export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */ _export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */ _this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */ - if (_this.pause_on_write && _this.player.popcorn.media.paused) { - _this.player.popcorn.play(); + if (_this.pause_on_write && _this.media.getPaused()) { + _this.media.play(); } - _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */ + _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */ }, error: function(_xhr, _error, _thrown) { IriSP.log("Error when sending annotation", _thrown); diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/DailymotionPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/DailymotionPlayer.js Wed Sep 19 15:03:51 2012 +0900 @@ -0,0 +1,104 @@ +IriSP.Widgets.DailymotionPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.DailymotionPlayer.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.DailymotionPlayer.prototype.defaults = { + aspect_ratio: 14/9 +} + +IriSP.Widgets.DailymotionPlayer.prototype.draw = function() { + + if (typeof this.video === "undefined") { + this.video = this.media.video; + } + + this.height = this.height || Math.floor(this.width / this.aspect_ratio); + + var _media = this.media, + _this = this, + _pauseState = true; + + /* Dailymotion utilise un système de fonctions référencées dans + * des variables globales pour la gestion des événements. + */ + + window.onDailymotionPlayerReady = function() { + + var _player = document.getElementById(_this.container); + + _media.getCurrentTime = function() { + return new IriSP.Model.Time(1000*_player.getCurrentTime()); + } + _media.getVolume = function() { + return _player.getVolume() / 100; + } + _media.getPaused = function() { + return _pauseState; + } + _media.getMuted = function() { + return _player.isMuted(); + } + _media.setCurrentTime = function(_milliseconds) { + _seekPause = _pauseState; + return _player.seekTo(_milliseconds / 1000); + } + _media.setVolume = function(_vol) { + return _player.setVolume(Math.floor(_vol*100)); + } + _media.mute = function() { + return _player.mute(); + } + _media.unmute = function() { + return _player.unMute(); + } + _media.play = function() { + return _player.playVideo(); + } + _media.pause = function() { + return _player.pauseVideo(); + } + + _player.addEventListener("onStateChange", "onDailymotionStateChange"); + _player.addEventListener("onVideoProgress", "onDailymotionVideoProgress"); + + _player.cueVideoByUrl(_this.video); + + _media.trigger("loadedmetadata"); + } + + window.onDailymotionStateChange = function(_state) { + switch(_state) { + case 1: + _media.trigger("play"); + _pauseState = false; + break; + + case 2: + _media.trigger("pause"); + _pauseState = true; + break; + + case 3: + _media.trigger("seeked"); + break; + } + } + + window.onDailymotionVideoProgress = function(_progress) { + _media.trigger("timeupdate", new IriSP.Model.Time(_progress.mediaTime * 1000)); + } + + var params = { + "allowScriptAccess" : "always", + "wmode": "opaque" + }; + + var atts = { + id : this.container + }; + + swfobject.embedSWF("http://www.dailymotion.com/swf?chromeless=1&enableApi=1", this.container, this.width, this.height, "8", null, null, params, atts); + +} \ No newline at end of file diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/JwpPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/JwpPlayer.js Wed Sep 19 15:03:51 2012 +0900 @@ -0,0 +1,119 @@ +IriSP.Widgets.JwpPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.JwpPlayer.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.JwpPlayer.prototype.defaults = { +} + +IriSP.Widgets.JwpPlayer.prototype.draw = function() { + + var _opts = {}, + _player = jwplayer(this.$[0]), + _seekPause = false, + _pauseState = true, + _props = [ "live", "provider", "autostart" ]; + + if (typeof this.video === "undefined") { + this.video = this.media.video; + } + + if (typeof this.streamer === "function") { + this.streamer = this.streamer(this.video); + } + + if (typeof this.streamer === "string") { + this.video = this.video.replace(this.streamer,""); + _opts.streamer = this.streamer; + } + + _opts.file = this.video; + _opts.flashplayer = IriSP.getLib("jwPlayerSWF"); + _opts["controlbar.position"] = "none"; + _opts.width = this.width; + _opts.height = this.height || Math.floor(.643*this.width); + + for (var i = 0; i < _props.length; i++) { + if (typeof this[_props[i]] !== "undefined") { + _opts[_props[i]] = this[_props[i]]; + } + } + + if (this.autostart) { + _pauseState = false; + this.media.trigger("play"); + } + // Binding functions to jwplayer + + this.media.getCurrentTime = function() { + return new IriSP.Model.Time(1000*_player.getPosition() || 0); + } + this.media.getVolume = function() { + return _player.getVolume() / 100; + } + this.media.getPaused = function() { + return _pauseState; + } + this.media.getMuted = function() { + return _player.getMute(); + } + this.media.setCurrentTime = function(_milliseconds) { + _seekPause = _pauseState; + return _player.seek(_milliseconds / 1000); + } + this.media.setVolume = function(_vol) { + return _player.setVolume(Math.floor(_vol*100)); + } + this.media.mute = function() { + return _player.setMute(true); + } + this.media.unmute = function() { + return _player.setMute(false); + } + this.media.play = function() { + return _player.play(true); + } + this.media.pause = function() { + return _player.pause(true); + } + + // Binding jwplater events to media + + var _media = this.media; + + _opts.events = { + onReady: function() { + _media.trigger("loadedmetadata"); + }, + onTime: function(_progress) { + if (_seekPause) { + _player.pause(true); + _seekPause = false; + } else { + if (_pauseState && _player.getState() === "PLAYING") { + _pauseState = false; + _media.trigger("play"); + } + } + _media.trigger("timeupdate", new IriSP.Model.Time(_progress.position * 1000)); + }, + onPlay: function() { + if (!_seekPause) { + _pauseState = false; + _media.trigger("play"); + } + }, + onPause: function() { + _pauseState = true; + _media.trigger("pause"); + }, + onSeek: function() { + _media.trigger("seeked"); + } + } + _player.setup(_opts); + + this.jwplayer = _player; + +} \ No newline at end of file diff -r 45e655657f7a -r 18dfa62b411a src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js --- a/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js Wed Sep 19 01:53:14 2012 +0900 +++ b/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js Wed Sep 19 15:03:51 2012 +0900 @@ -20,11 +20,11 @@ v2.0.3 (c) Kyle Simpson MIT License */ -(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);/* init.js - initialization and configuration of Popcorn and the widgets +(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);/* init.js - initialization and configuration of the widgets */ if (typeof window.IriSP === "undefined") { - IriSP = {}; + window.IriSP = {}; } /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ @@ -32,43 +32,34 @@ IriSP.Metadataplayer = function(config) { IriSP.log("IriSP.Metadataplayer constructor"); for (var key in IriSP.guiDefaults) { - if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { - config.gui[key] = IriSP.guiDefaults[key] + if (IriSP.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) { + config[key] = IriSP.guiDefaults[key] } } - var _container = document.getElementById(config.gui.container); + var _container = document.getElementById(config.container); _container.innerHTML = '

Loading... Chargement...

'; this.sourceManager = new IriSP.Model.Directory(); this.config = config; - this.callbackQueue = []; - this.isLoaded = false; + this.__events = {}; this.loadLibs(); } IriSP.Metadataplayer.prototype.toString = function() { - return 'Metadataplayer in #' + this.config.gui.container; -} - -IriSP.Metadataplayer.prototype.deferCallback = function(_callback) { - var _this = this; - IriSP._.defer(function() { - _callback.call(_this); - }); + return 'Metadataplayer in #' + this.config.container; } -IriSP.Metadataplayer.prototype.handleCallbacks = function() { - this.isLoaded = true; - while (this.callbackQueue.length) { - this.deferCallback(this.callbackQueue.splice(0,1)[0]); +IriSP.Metadataplayer.prototype.on = function(_event, _callback) { + if (typeof this.__events[_event] === "undefined") { + this.__events[_event] = []; } + this.__events[_event].push(_callback); } -IriSP.Metadataplayer.prototype.onLoad = function(_callback) { - if (this.isLoaded) { - this.deferCallback(_callback); - } else { - this.callbackQueue.push(_callback); - } +IriSP.Metadataplayer.prototype.trigger = function(_event, _data) { + var _element = this; + IriSP._(this.__events[_event]).each(function(_callback) { + _callback.call(_element, _data); + }); } IriSP.Metadataplayer.prototype.loadLibs = function() { @@ -76,8 +67,7 @@ var $L = $LAB .script(IriSP.getLib("underscore")) .script(IriSP.getLib("Mustache")) - .script(IriSP.getLib("jQuery")) - .script(IriSP.getLib("swfObject")); + .script(IriSP.getLib("jQuery")); if (typeof JSON == "undefined") { $L.script(IriSP.getLib("json")); @@ -86,17 +76,9 @@ $L.wait() .script(IriSP.getLib("jQueryUI")); - if (this.config.player.type === "jwplayer" || this.config.player.type === "auto") { - $L.script(IriSP.getLib("jwplayer")); - } - - if (this.config.player.type !== "jwplayer" && this.config.player.type !== "allocine" && this.config.player.type !== "dailymotion") { - $L.script(IriSP.getLib("popcorn")); - } - /* widget specific requirements */ - for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { - var _t = this.config.gui.widgets[_i].type; + for(var _i = 0; _i < this.config.widgets.length; _i++) { + var _t = this.config.widgets[_i].type; if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) { for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) { $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j])); @@ -120,22 +102,25 @@ IriSP._ = window._; } IriSP.loadCss(IriSP.getLib("cssjQueryUI")); - IriSP.loadCss(this.config.gui.css); + IriSP.loadCss(this.config.css); - this.videoData = this.loadMetadata(this.config.player.metadata); - this.$ = IriSP.jQuery('#' + this.config.gui.container); + this.$ = IriSP.jQuery('#' + this.config.container); this.$.css({ - "width": this.config.gui.width, + "width": this.config.width, "clear": "both" }); - if (typeof this.config.gui.height !== "undefined") { - this.$.css("height", this.config.gui.height); + if (typeof this.config.height !== "undefined") { + this.$.css("height", this.config.height); } + this.widgets = []; var _this = this; - this.videoData.onLoad(function() { - _this.onVideoDataLoaded(); - }); + for(var i = 0; i < this.config.widgets.length; i++) { + this.loadWidget(this.config.widgets[i], function(_widget) { + _this.widgets.push(_widget) + }); + }; + this.$.find('.Ldt-Loader').detach(); } IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) { @@ -152,197 +137,6 @@ } } -IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { - - /* Setting default media from metadata */ - - if (typeof this.videoData !== "undefined") { - - var _media; - - if (typeof this.videoData.mainMedia !== "undefined") { - _media = this.videoData.getElement(this.videoData.mainMedia); - } - - if (this.config.player.type === "mashup" || this.config.player.type === "mashup-html") { - if (typeof _media === "undefined" || _media.elementType !== "mashup") { - var _mashups = this.videoData.getMashups(); - if (_mashups.length) { - _media = _mashups[0]; - } - } - } else { - if (typeof _media === "undefined" || _media.elementType !== "media") { - var _medias = this.videoData.getMedias(); - if (_medias.length) { - _media = _medias[0]; - } - } - } - - this.videoData.currentMedia = _media; - - /* Getting video URL from metadata if it's not in the player config options */ - - if (typeof _media !== "undefined" && typeof _media.video !== "undefined" && typeof this.config.player.video === "undefined") { - this.config.player.video = _media.video; - if (typeof this.config.player.streamer == "undefined" && typeof _media.streamer !== "undefined") { - this.config.player.streamer = _media.streamer; - } - } - - } - - if (typeof this.config.player.video === "string" && this.config.player.url_transform === "function") { - this.config.player.video = this.config.player.url_transform(this.config.player.video); - } - - var _pop, - _divs = this.layoutDivs("video",this.config.player.height || undefined), - containerDiv = _divs[0], - spacerDiv = _divs[1], - _this = this, - _types = { - "html5" : /\.(ogg|ogv|webm)$/, - "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, - "vimeo" : /^(https?:\/\/)?(www\.)?vimeo\.com/, - "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ - }; - - if (this.config.player.type === "auto") { - this.config.player.type = "jwplayer"; - IriSP._(_types).each(function(_v, _k) { - if (_v.test(_this.config.player.video)) { - _this.config.player.type = _k - } - }); - } - - switch(this.config.player.type) { - case "html5": - var _tmpId = Popcorn.guid("video"), - _videoEl = IriSP.jQuery('