fix: lancement vidéo YouTube via IFrame Player API

- Remplacement iframe par div#youtube-player avec data-video-id
- ID vidéo extrait du videoUrl via regex côté PHP
- Chargement de l'API YouTube IFrame au load
- Création du player + playVideo() dans onReady au clic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-27 16:32:58 +01:00
parent 76add8b87f
commit 05604ea6ef
2 changed files with 37 additions and 23 deletions

View file

@ -32,9 +32,12 @@ $dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
<button id="hero-play-video"><span class="btn--bold"><?= svg('assets/icons/play.svg') ?> <span class="text">play video</span></button>
</div>
<?php endif ?>
<?php if ($page->videoUrl()->isNotEmpty()): ?>
<?php if ($page->videoUrl()->isNotEmpty()):
preg_match('/(?:embed\/|v=|youtu\.be\/)([a-zA-Z0-9_-]+)/', $page->videoUrl()->value(), $m);
$videoId = $m[1] ?? '';
?>
<div class="video-full">
<iframe rel="0" frameborder="0" allowfullscreen="" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" title="<?= $page->title()->esc() ?>" width="480" height="320" src="<?= $page->videoUrl() ?>"></iframe>
<div id="youtube-player" data-video-id="<?= $videoId ?>"></div>
</div>
<?php endif ?>
</div>