From da12821f5eac4fa7978bc86aa41b20237e46a247 Mon Sep 17 00:00:00 2001 From: amtins Date: Fri, 10 Nov 2023 16:48:28 +0100 Subject: [PATCH] fix(player): reset CSS classes at player.reset Allows CSS classes to be reset when `player.reset` is called, so that the player is close to its initial state. - remove `vjs-playing` - add `vjs-paused` --- src/js/player.js | 4 ++++ test/unit/player.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/js/player.js b/src/js/player.js index df362e3b6f..81f8bf9a62 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -3599,6 +3599,10 @@ class Player extends Component { if (this.tech_) { this.tech_.clearTracks('text'); } + + this.removeClass('vjs-playing'); + this.addClass('vjs-paused'); + this.resetCache_(); this.poster(''); this.loadTech_(this.options_.techOrder[0], null); diff --git a/test/unit/player.test.js b/test/unit/player.test.js index 7253a8fd0f..f39fca34d2 100644 --- a/test/unit/player.test.js +++ b/test/unit/player.test.js @@ -1911,6 +1911,8 @@ QUnit.test('player#reset loads the Html5 tech and then techCalls reset', functio techOrder: ['html5', 'youtube'] }, error() {}, + addClass() {}, + removeClass() {}, resetCache_() {}, loadTech_(tech, source) { loadedTech = tech; @@ -1944,6 +1946,8 @@ QUnit.test('player#reset loads the first item in the techOrder and then techCall techOrder: ['youtube', 'html5'] }, error() {}, + addClass() {}, + removeClass() {}, resetCache_() {}, loadTech_(tech, source) { loadedTech = tech;