diff -r 02c04d2c8fd8 -r ac1eacb3aa33 src/widgets/HtmlMashupPlayer.js --- a/src/widgets/HtmlMashupPlayer.js Sun Nov 12 22:07:33 2017 +0100 +++ b/src/widgets/HtmlMashupPlayer.js Wed Sep 04 17:32:50 2024 +0200 @@ -1,42 +1,42 @@ -IriSP.Widgets.HtmlMashupPlayer = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); -}; +//HtmlMashupPlayer -IriSP.Widgets.HtmlMashupPlayer.prototype = new IriSP.Widgets.Widget(); - +const HtmlMashupPlayer = function (ns) { + return class extends ns.Widgets.Widget { + constructor(player, config) { + super(player, config); + } -IriSP.Widgets.HtmlMashupPlayer.prototype.defaults = { - aspect_ratio: 14/9, - background: "#333333" -}; + static defaults = { + aspect_ratio: 14 / 9, + background: "#333333", + }; -IriSP.Widgets.HtmlMashupPlayer.prototype.draw = function() { - - if (!this.height && this.aspect_ratio) { + draw() { + if (!this.height && this.aspect_ratio) { this.height = this.width / this.aspect_ratio; this.$.css("height", this.height); - } - - if (this.background) { + } + + if (this.background) { this.$.css("background", this.background); - } - - var mashup = this.media, + } + + 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, + + mashup.currentMedia = null; + mashup.currentAnnotation = null; + mashup.seeking = false; + var mashupSegmentBegin, mashupSegmentEnd, mashupTimecode = 0, - // seekdiv = $(".video-wait"), + // seekdiv = $(".video-wait"), mashupTimedelta; - -/* + + /* function showSeek() { if (currentMedia.seeking) { seekdiv.show(); @@ -44,302 +44,328 @@ } */ - function changeCurrentAnnotation() { + function changeCurrentAnnotation() { if (mashupTimecode >= mashup.duration) { - if (!mashup.paused) { - mashup.paused = true; - mashup.trigger("pause"); - } - mashupTimecode = 0; + if (!mashup.paused) { + mashup.paused = true; + mashup.trigger("pause"); + } + mashupTimecode = 0; } - var _annotation = mashup.getAnnotationAtTime( mashupTimecode ); + var _annotation = mashup.getAnnotationAtTime(mashupTimecode); if (typeof _annotation === "undefined") { - if (mashup.currentMedia) { - mashup.currentMedia.pause(); - if (!mashup.paused) { - mashup.paused = true; - mashup.trigger("pause"); - } + if (mashup.currentMedia) { + mashup.currentMedia.pause(); + if (!mashup.paused) { + mashup.paused = true; + mashup.trigger("pause"); } - return; + } + return; } mashup.currentAnnotation = _annotation; - mashupSegmentBegin = mashup.currentAnnotation.annotation.begin.milliseconds; + mashupSegmentBegin = + mashup.currentAnnotation.annotation.begin.milliseconds; mashupSegmentEnd = mashup.currentAnnotation.annotation.end.milliseconds; - mashupTimedelta = mashupSegmentBegin - mashup.currentAnnotation.begin.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.getMedias().forEach(function (_media) { + if (_media !== mashup.currentMedia) { + _media.hide(); + _media.pause(); + } else { + _media.show(); + } }); - - mashup.currentMedia.setCurrentTime( mashupTimecode + mashupTimedelta); + + 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 (!mashup.paused) { + mashup.currentMedia.play(); + mashup.seeking = true; + // setTimeout(showSeek,200); + } + mashup.trigger("timeupdate", new ns.Model.Time(mashupTimecode)); + } + + mashup.getMedias().forEach(addMedia); + changeCurrentAnnotation(); + mashup.trigger("loadedmetadata"); + + function addMedia(media) { if (media.has_player) { - return; + return; } media.has_player = true; var videourl = media.video; if (typeof url_transform === "function") { - videourl = url_transform(media.video); + 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 = $('