Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
Cómo detener el video después de hacer clic en el botón X

Actualmente, el video no player.stopVideo(); en el código.

Para reproducir: Haga clic en el botón de reproducción de 1 svg, luego haga clic en la X y lo verá.

¿Cómo se corrige eso en el código para que el mismo video se detenga después de hacer clic en la X ?

Códigos actualizados:

Haga clic en Ejecutar , no actualizar para probar el código JSitor:

Además, la reproducción automática funciona dentro de JSitor: https://jsitor.com/qYKcpdB0tj

Copia de seguridad: https://jsfiddle.net/0q63tr2m/

 const videoPlayer = (function makeVideoPlayer() { const players = []; const tag = document.createElement("script"); tag.src = "https://www.youtube.com/player_api"; const firstScriptTag = document.getElementsByTagName("script")[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); function onPlayerReady(event) { const player = event.target; player.setVolume(100); } function addPlayer(video, settings) { const defaults = { height: 360, host: "https://www.youtube-nocookie.com", videoId: video.dataset.id, width: 640 }; defaults.events = { "onReady": onPlayerReady };

Puedes ver el video todavía reproduciéndose aquí:

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Lo que tienes que hacer es lo siguiente:

  1. Agregue una identificación a su elemento iframe así: id="iframe"
  2. Eliminar player.stopVideo(); de la función createStopHandler
  3. En su función createStopHandler , agregue el siguiente código (si desea que su video se detenga y no se pause, cambie el fragmento de "func":"pauseVideo" a "func":"stopVideo" ):

 var frame = document.getElementById("iframe"); frame.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');

Esto debería hacerlo. Aquí puedes verlo funcionando: https://jsfiddle.net/vjbex6t1/8/

about 4 years ago · Juan Pablo Isaza Report

0

 function addClickToHome(goHome) { goHome.forEach(function addEventHandler(goHome) { goHome.addEventListener("click", homeClickHandler); //STOP PLAYER AFTER HOME IS CLICKED }); }

Inicialice alguna variable con el reproductor globalmente y deténgala cuando se presione el botón para ir a casa

about 4 years ago · Juan Pablo Isaza Report

0

Puedes probar esto,

 var videoURL = $('#playerID').prop('src'); videoURL = videoURL.replace("&autoplay=1", ""); $('#playerID').prop('src',''); $('#playerID').prop('src',videoURL);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!