Skip to content

Commit

Permalink
Use fetch instead of decode
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored Dec 16, 2024
1 parent 2abc188 commit d43ab54
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions media-session/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ video.srcObject = canvas.captureStream();
video.muted = true;

async function showPictureInPictureWindow() {
const image = new Image();
image.crossOrigin = true;
image.src = [...navigator.mediaSession.metadata.artwork].pop().src;
await image.decode();
const response = await fetch([...navigator.mediaSession.metadata.artwork].pop().src);
const blob = await response.blob();
const image = await createImageBitmap(blob);

canvas.getContext('2d').drawImage(image, 0, 0, 512, 512);
await video.play();
Expand Down

0 comments on commit d43ab54

Please sign in to comment.