Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always show poster images for audio playlists #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/playlist-maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
}

Expand Down
6 changes: 6 additions & 0 deletions test/player-proxy-maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {},
Expand All @@ -15,6 +16,11 @@ const proxy = (props) => {
src: () => {},
currentSrc: () => {},
addRemoteTextTrack: () => {},
isAudio: (audio) => {
if (audio !== undefined) {
audio_ = audio;
} return audio_;
},
removeRemoteTextTrack: () => {},
remoteTextTracks: () => {},
playlist: () => [],
Expand Down
11 changes: 11 additions & 0 deletions test/playlist-maker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(), []);

Expand Down