Skip to content

Commit

Permalink
feat(Demo): Show APIC(ID3) as poster for audio only streams (#6122)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jan 19, 2024
1 parent 938de98 commit 291b497
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion demo/main.js
Expand Up @@ -390,6 +390,21 @@ shakaDemo.Main = class {
const ui = video['ui'];
this.player_ = ui.getControls().getPlayer();

// Change the poster by the APIC ID3 if the stream is audio only.
this.player_.addEventListener('metadata', (event) => {
if (!this.player_.isAudioOnly()) {
return;
}
const payload = event['payload'];
if (payload &&
payload['key'] == 'APIC' && payload['mimeType'] == '-->') {
const url = payload['data'];
if (url && url != video.poster) {
video.poster = url;
}
}
});

if (!this.noInput_) {
// Don't add the close button if in noInput mode; it doesn't make much
// sense to stop playing a video if you can't start playing other videos.
Expand Down Expand Up @@ -1268,7 +1283,8 @@ shakaDemo.Main = class {
/* startTime= */ null,
asset.mimeType || undefined);

if (this.player_.isAudioOnly()) {
if (this.player_.isAudioOnly() &&
this.video_.poster == shakaDemo.Main.mainPoster_) {
this.video_.poster = shakaDemo.Main.audioOnlyPoster_;
}

Expand Down

0 comments on commit 291b497

Please sign in to comment.