index-main/assets/js/hero-video.js
Julie Blanc f2ca803842
All checks were successful
Deploy / Deploy to Production (push) Successful in 11s
style investigation-summary
2026-01-13 10:44:32 +01:00

39 lines
984 B
JavaScript

export function playVideo() {
const playButton = document.querySelector('#hero-play-video');
if (!playButton) {
return;
}
playButton.addEventListener('click', function() {
const extract = document.querySelector('.extract');
const videoFull = document.querySelector('.video-full');
const titleSmall = document.querySelector('.page-title-small');
if (extract) {
extract.style.display = 'none';
}
if(titleSmall){
titleSmall.style.display = 'none';
}
if (videoFull) {
videoFull.style.display = 'block';
const iframe = videoFull.querySelector('iframe');
if (iframe) {
const src = iframe.src;
// Ajouter les paramètres autoplay et mute pour YouTube
if (src) {
const separator = src.includes('?') ? '&' : '?';
iframe.src = src + separator + 'autoplay=1&mute=1';
iframe.setAttribute('allow', 'autoplay; encrypted-media');
}
}
}
});
}