# HG changeset patch # User ymh # Date 1440069940 -7200 # Node ID bc9244b671bdc30065a73216d5be7b99345cf800 # Parent 7fdc585c8cb4d6f54e0026bec12eab5da4dc26db update metedataplayer diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/AdaptivePlayer.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AdaptivePlayer.js Wed Jul 22 15:03:14 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AdaptivePlayer.js Thu Aug 20 13:25:40 2015 +0200 @@ -5,7 +5,7 @@ IriSP.Widgets.AdaptivePlayer.prototype = new IriSP.Widgets.Widget(); IriSP.Widgets.AdaptivePlayer.prototype.defaults = { - mime_type: "video/mp4", + mime_type: 'video/mp4; codecs="avc1.42E01E"', normal_player: "HtmlPlayer", fallback_player: "JwpPlayer" }; @@ -20,7 +20,7 @@ _opts = {}, _canPlayType = document.createElement('video').canPlayType(this.mime_type); - _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? this.normal_player : this.fallback_player; + _opts.type = (_canPlayType !== "no") ? this.normal_player : this.fallback_player; for (var i = 0; i < _props.length; i++) { if (typeof this[_props[i]] !== "undefined") { diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/Annotation.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Wed Jul 22 15:03:14 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Thu Aug 20 13:25:40 2015 +0200 @@ -41,9 +41,9 @@ + '

{{l10n.excerpt_from}} ' + '( - )

' + '
{{l10n.creator_}}
' - + '{{#show_creator}}

' - + '
{{l10n.description_}}
{{/show_creator}}' - + '

' + + '{{#show_creator}}

{{/show_creator}}' + + '{{#show_description}}
{{l10n.description_}}
' + + '

{{/show_description}}' + '
' + '
{{l10n.tags_}}
' + '
'; @@ -53,6 +53,7 @@ start_minimized: false, show_arrow : true, show_creator: true, + show_description: true, arrow_position: .5, site_name : "Lignes de Temps", search_on_tag_click: true, @@ -231,4 +232,4 @@ IriSP.Widgets.Annotation.prototype.maximize = function() { this.minimized = false; this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized"); -}; \ No newline at end of file +}; diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/AutoPlayer.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AutoPlayer.js Wed Jul 22 15:03:14 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AutoPlayer.js Thu Aug 20 13:25:40 2015 +0200 @@ -56,8 +56,8 @@ } if (_opts.type === "AdaptivePlayer") { - var _canPlayType = document.createElement('video').canPlayType("video/mp4"); - _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? "HtmlPlayer" : "JwpPlayer"; + var _canPlayType = document.createElement('video').canPlayType('video/mp4; codecs="avc1.42E01E"'); + _opts.type = (_canPlayType !== "no") ? "HtmlPlayer" : "JwpPlayer"; } if (_rtmprgx.test(this.video)) { diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/Controller.css --- a/src/ldt/ldt/static/ldt/metadataplayer/Controller.css Wed Jul 22 15:03:14 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Controller.css Thu Aug 20 13:25:40 2015 +0200 @@ -86,7 +86,7 @@ } input.Ldt-Ctrl-SearchInput { - width: 145px; height: 13px; margin: 2px; padding: 3px; + width: 145px; height: 20px; margin: 2px; padding: 3px; border: 1px solid #8080a0; border-radius: 3px; font-size: 13px; } diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/Controller.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Wed Jul 22 15:03:14 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Thu Aug 20 13:25:40 2015 +0200 @@ -10,7 +10,8 @@ IriSP.Widgets.Controller.prototype.defaults = { disable_annotate_btn: false, disable_search_btn: false, - disable_ctrl_f: false + disable_ctrl_f: false, + always_show_search: false }; IriSP.Widgets.Controller.prototype.template = @@ -27,7 +28,7 @@ + '
' + '{{/disable_search_btn}}' + '' + '' + '
' @@ -102,6 +103,7 @@ this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); this.$searchInput.keyup(this.functionWrapper("searchHandler")); + this.$searchInput.on("search", this.functionWrapper("searchHandler")); var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control"); this.$.find('.Ldt-Ctrl-Sound') @@ -168,7 +170,9 @@ annotations.on("search-cleared", function() { _this.hideSearchBlock(); }); - + if (_this.always_show_search) { + _this.showSearchBlock(); + } }; /* Update the elasped time div */ @@ -237,7 +241,9 @@ }; IriSP.Widgets.Controller.prototype.hideSearchBlock = function() { - this.$searchBlock.animate( { width: 0 }, 200); + if (! this.always_show_search) { + this.$searchBlock.animate( { width: 0 }, 200); + } }; /** react to clicks on the search button */ diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/Highlighter.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Highlighter.css Thu Aug 20 13:25:40 2015 +0200 @@ -0,0 +1,3 @@ +.currentAnnotation { + border: solid 3px red; +} diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/Highlighter.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Highlighter.js Thu Aug 20 13:25:40 2015 +0200 @@ -0,0 +1,43 @@ +IriSP.Widgets.Highlighter = function(player, config) { + var _this = this; + IriSP.Widgets.Widget.call(this, player, config); + this.throttledRefresh = IriSP._.throttle(function() { + console.log("highlighter Refresh"); + _this.update(); + }, 800); +}; + +/** + * Highlighter widget + * This widgets highlights the current annotations by setting the + * .activeAnnotation class on appropriate .Ldt-Highlighter-Annotation + * elements. These elements *must* have data-begin and data-end properties specifying their bounds (in ms) (and data-media specifying the media-id) + */ +IriSP.Widgets.Highlighter.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.Highlighter.prototype.defaults = { +} + +IriSP.Widgets.Highlighter.prototype.update = function() { + var _this = this; + var _currentTime = _this.media.getCurrentTime(); + _this.$.find(".Ldt-Highlighter-Annotation", document).toggleClass("currentAnnotation", function () { + return (this.dataset.media === _this.media.id && this.dataset.begin <= _currentTime && _currentTime < this.dataset.end); + }); + console.log(_this.$.find(".currentAnnotation")); + return false; +}; + +IriSP.Widgets.Highlighter.prototype.draw = function() { + var _this = this; + + var _events = [ + "timeupdate", + "seeked", + "loadedmetadata" + ]; + for (var _i = 0; _i < _events.length; _i++) { + _this.onMediaEvent(_events[_i], _this.throttledRefresh); + } + _this.throttledRefresh(); +}; diff -r 7fdc585c8cb4 -r bc9244b671bd src/ldt/ldt/static/ldt/metadataplayer/HtmlMashupPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/HtmlMashupPlayer.js Thu Aug 20 13:25:40 2015 +0200 @@ -0,0 +1,345 @@ +IriSP.Widgets.HtmlMashupPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.HtmlMashupPlayer.prototype = new IriSP.Widgets.Widget(); + + +IriSP.Widgets.HtmlMashupPlayer.prototype.defaults = { + aspect_ratio: 14/9, + background: "#333333" +}; + +IriSP.Widgets.HtmlMashupPlayer.prototype.draw = function() { + + if (!this.height && this.aspect_ratio) { + this.height = this.width / this.aspect_ratio; + this.$.css("height", this.height); + } + + if (this.background) { + this.$.css("background", this.background); + } + + var mashup = this.media, + sel = this.$, + width = this.width, + height = this.height, + url_transform = this.url_transform; + + mashup.currentMedia = null; + mashup.currentAnnotation = null; + mashup.seeking = false; + var mashupSegmentBegin, + mashupSegmentEnd, + mashupTimecode = 0, + // seekdiv = $(".video-wait"), + mashupTimedelta; + +/* + function showSeek() { + if (currentMedia.seeking) { + seekdiv.show(); + } + } +*/ + + function changeCurrentAnnotation() { + if (mashupTimecode >= mashup.duration) { + if (!mashup.paused) { + mashup.paused = true; + mashup.trigger("pause"); + } + mashupTimecode = 0; + } + var _annotation = mashup.getAnnotationAtTime( mashupTimecode ); + if (typeof _annotation === "undefined") { + if (mashup.currentMedia) { + mashup.currentMedia.pause(); + if (!mashup.paused) { + mashup.paused = true; + mashup.trigger("pause"); + } + } + return; + } + mashup.currentAnnotation = _annotation; + mashupSegmentBegin = mashup.currentAnnotation.annotation.begin.milliseconds; + mashupSegmentEnd = mashup.currentAnnotation.annotation.end.milliseconds; + mashupTimedelta = mashupSegmentBegin - mashup.currentAnnotation.begin.milliseconds; + mashup.currentMedia = mashup.currentAnnotation.getMedia(); + mashup.getMedias().forEach(function(_media) { + if (_media !== mashup.currentMedia) { + _media.hide(); + _media.pause(); + } else { + _media.show(); + } + }); + + mashup.currentMedia.setCurrentTime( mashupTimecode + mashupTimedelta); + mashup.currentMedia.seeking = true; + + if (!mashup.paused) { + mashup.currentMedia.play(); + mashup.seeking = true; +// setTimeout(showSeek,200); + } + mashup.trigger("timeupdate", new IriSP.Model.Time(mashupTimecode)); + + } + + mashup.getMedias().forEach(addMedia); + changeCurrentAnnotation(); + mashup.trigger("loadedmetadata"); + + function addMedia(media) { + if (media.has_player) { + return; + } + media.has_player = true; + var videourl = media.video; + if (typeof url_transform === "function") { + videourl = url_transform(media.video); + } + var videoid = "video_" + media.id, + videoElement; + + media.show = function() { + + if (document.getElementById(videoid)) { + return; + } + + media.loaded = false; + media.paused = true; + var videoSelector = $('