From 8f2853328871c25ca88592aa6901a3c3ed3994f9 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 2 Feb 2021 12:35:28 +0100 Subject: [PATCH] Set initial startitme after the video is loaded --- api/js/etemplate/et2_widget_video.js | 17 +++++++++++++---- api/js/etemplate/et2_widget_video.ts | 24 +++++++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/api/js/etemplate/et2_widget_video.js b/api/js/etemplate/et2_widget_video.js index 24f0989a10..50f208b9e8 100644 --- a/api/js/etemplate/et2_widget_video.js +++ b/api/js/etemplate/et2_widget_video.js @@ -24,7 +24,6 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -exports.et2_video = void 0; /*egw:uses /vendor/bower-asset/jquery/dist/jquery.js; et2_core_interfaces; @@ -98,9 +97,6 @@ var et2_video = /** @class */ (function (_super) { if (this.options.src_type) { source.attr('type', this.options.src_type); } - if (this.options.starttime) { - this.seek_video(this.options.starttime); - } } }; /** @@ -164,6 +160,19 @@ var et2_video = /** @class */ (function (_super) { et2_video.prototype.currentTime = function () { return this.video[0].currentTime; }; + et2_video.prototype.doLoadingFinished = function () { + _super.prototype.doLoadingFinished.call(this); + var self = this; + this.video[0].addEventListener("loadedmetadata", function () { + self.videoLoadnigIsFinished(); + }); + return false; + }; + et2_video.prototype.videoLoadnigIsFinished = function () { + if (this.options.starttime) { + this.seek_video(this.options.starttime); + } + }; et2_video._attributes = { "video_src": { "name": "Video", diff --git a/api/js/etemplate/et2_widget_video.ts b/api/js/etemplate/et2_widget_video.ts index c60b4fb0ba..9857a404f8 100644 --- a/api/js/etemplate/et2_widget_video.ts +++ b/api/js/etemplate/et2_widget_video.ts @@ -148,11 +148,6 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode { source.attr('type', this.options.src_type); } - - if (this.options.starttime) - { - this.seek_video(this.options.starttime); - } } } @@ -234,5 +229,24 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode { return this.video[0].currentTime; } + + doLoadingFinished(): boolean + { + super.doLoadingFinished(); + let self = this; + + this.video[0].addEventListener("loadedmetadata", function(){ + self.videoLoadnigIsFinished(); + }); + return false; + } + + public videoLoadnigIsFinished() + { + if (this.options.starttime) + { + this.seek_video(this.options.starttime); + } + } } et2_register_widget(et2_video, ["video"]); \ No newline at end of file