From 66e7754a0d950816fb88e4d17305ac046a39c731 Mon Sep 17 00:00:00 2001 From: Yoriiis <2563298+yoriiis@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:46:47 +0200 Subject: [PATCH] Fix duration when preload is disabled --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- src/core/player.ts | 15 ++++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f3d948..0e7dfedd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 6.0.4 + +### Fixes + +- Fix duration when preload is disabled ([#136](https://github.com/vlitejs/vlite/pull/136)) + ## 6.0.3 ### Fixes diff --git a/package-lock.json b/package-lock.json index a1ea13c8..1b5e4e08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vlitejs", - "version": "6.0.3", + "version": "6.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vlitejs", - "version": "6.0.3", + "version": "6.0.4", "license": "MIT", "dependencies": { "validate-target": "^3.1.1" diff --git a/package.json b/package.json index b52aabd2..f97bfc40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vlitejs", - "version": "6.0.3", + "version": "6.0.4", "description": "vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)", "keywords": [ "video", diff --git a/src/core/player.ts b/src/core/player.ts index 8809a861..6d2c8305 100644 --- a/src/core/player.ts +++ b/src/core/player.ts @@ -202,13 +202,22 @@ export default class Player { this.Vlitejs.onReady instanceof Function && this.Vlitejs.onReady.call(this, this) - // Call the onReady functions of components + if (this.media.preload === 'none' && this.Vlitejs.provider === 'html5') { + this.media.addEventListener('loadedmetadata', () => this.triggerOnReady()) + } else { + this.triggerOnReady() + } + this.loading(false) + } + + /** + * Trigger on ready component's functions + */ + triggerOnReady() { this.options.controls && this.controlBar.onReady() Object.keys(this.plugins).forEach((id) => { this.plugins[id].onReady instanceof Function && this.plugins[id].onReady() }) - - this.loading(false) } /**