
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');
        }
      }
    }
  });
}
