From 347e9407e7bd6f8f422f5678c29f479c76ef618a Mon Sep 17 00:00:00 2001 From: Brad Greco Date: Tue, 29 Aug 2023 08:41:02 -0400 Subject: [PATCH] Always show poster images for audio playlists --- src/playlist-maker.js | 2 +- test/player-proxy-maker.js | 6 ++++++ test/playlist-maker.test.js | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/playlist-maker.js b/src/playlist-maker.js index 335813e..8bfa204 100644 --- a/src/playlist-maker.js +++ b/src/playlist-maker.js @@ -319,7 +319,7 @@ export default function factory(player, initialList, initialIndex = 0) { // this by hiding every poster after the first play list item. This // doesn't cover every use case for showing/hiding the poster, but // it will significantly improve the user experience. - if (index > 0) { + if (index > 0 && !player.isAudio()) { player.poster(''); } diff --git a/test/player-proxy-maker.js b/test/player-proxy-maker.js index 155ee81..99ab09d 100644 --- a/test/player-proxy-maker.js +++ b/test/player-proxy-maker.js @@ -3,6 +3,7 @@ import videojs from 'video.js'; const proxy = (props) => { let poster_ = ''; + let audio_ = false; const player = Object.assign({}, videojs.EventTarget.prototype, { play: () => {}, paused: () => {}, @@ -15,6 +16,11 @@ const proxy = (props) => { src: () => {}, currentSrc: () => {}, addRemoteTextTrack: () => {}, + isAudio: (audio) => { + if (audio !== undefined) { + audio_ = audio; + } return audio_; + }, removeRemoteTextTrack: () => {}, remoteTextTracks: () => {}, playlist: () => [], diff --git a/test/playlist-maker.test.js b/test/playlist-maker.test.js index 26ae9ef..e0bb545 100644 --- a/test/playlist-maker.test.js +++ b/test/playlist-maker.test.js @@ -185,6 +185,17 @@ QUnit.test('playlist.currentItem() hides the poster for all videos after the fir } }); +QUnit.test('playlist.currentItem() always shows the poster for audio players', function(assert) { + const player = playerProxyMaker(); + const playlist = playlistMaker(player, videoList); + + player.isAudio(true); + for (let i = 1; i <= playlist.lastIndex(); i++) { + playlist.currentItem(i); + assert.notEqual(player.poster(), '', 'poster is shown for audio playlist index ' + i); + } +}); + QUnit.test('playlist.currentItem() returns -1 with an empty playlist', function(assert) { const playlist = playlistMaker(playerProxyMaker(), []);