Changeset b56afa7 in Klonkt for src/assets


Ignore:
Timestamp:
06/20/2026 04:08:28 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d43ea3f
Parents:
976d36d
Message:

feat(embed): show real YouTube title on the audio-only card

YT oEmbed has no CORS → new same-origin proxy GET /audio/yt-title (server
fetches oEmbed + caches it). The audio-only embed now shows the real video
title instead of "YouTube", and passes it to the site player. buster
embed-player.js?v=11.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/assets/js/embed-player.js

    r976d36d rb56afa7  
    233233    let preMuteVol = 100;
    234234    // Audio-only YouTube: zet de thumbnail als albumhoes op de audio-kaart.
     235    let ytTitle = '';  // echte videotitel (via same-origin oEmbed-proxy)
    235236    if (audioOnly && ytThumb) {
    236237      const art0 = el.querySelector('.pcms-embed-art');
    237238      if (art0) { art0.style.backgroundImage = `url('${ytThumb}')`; art0.classList.add('has-art'); }
     239      // Haal de echte titel op (server-proxy, want YT-oEmbed heeft geen CORS) en
     240      // toon 'm i.p.v. "YouTube".
     241      fetch('/audio/yt-title?url=' + encodeURIComponent(url))
     242        .then((r) => (r.ok ? r.json() : null))
     243        .then((d) => {
     244          if (d && d.title) {
     245            ytTitle = d.title;
     246            const tt = el.querySelector('.pcms-embed-title');
     247            if (tt) tt.textContent = d.title;
     248          }
     249        })
     250        .catch(() => {});
    238251    }
    239252
     
    314327      // én doorspelen bij navigeren. De inline-kaart is enkel de launcher.
    315328      if (audioOnly && window.pcmsAudioPlayer && typeof window.pcmsAudioPlayer.playYouTube === 'function') {
    316         window.pcmsAudioPlayer.playYouTube({ id: ytId(ref, url), cover: ytThumb, postUrl: location.pathname + location.search });
     329        window.pcmsAudioPlayer.playYouTube({ id: ytId(ref, url), title: ytTitle || undefined, cover: ytThumb, postUrl: location.pathname + location.search });
    317330        el.classList.add('pcms-embed-elsewhere');
    318331        return;
Note: See TracChangeset for help on using the changeset viewer.