Skip to main content
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

YouTube Embed Examples - Play one at a time

If you want a playing YouTube video to stop before another starts please add this code to the Additional JavaScript tags TeamSite template component.:

<script src="/scripts/youTube.js"></script>    

And update your iframe tags. See specific examples below

// This script will prevent two embedded YouTube videos from playing at the same time.
// iframe tag needs ?html5=1&enablejsapi=1 on the src=

See also Easiest Way to Download YouTube Transcript / Subtitles as Plain Text for how to retrieve the text of transcript uploaded to YouTube.



Append ?html5=1&enablejsapi=1 to the src= paramater

<iframe class="youtube-video" title="NLM embedded YouTube video player example" src="https://www.youtube.com/embed/GQigLJ6iV4Y?html5=1&enablejsapi=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>



Append ?html5=1&enablejsapi=1 to the src= paramater

See example on the the highlighted code below.

In some cases adding ?html5=1&enablejsapi=1  will cause an error. In those cases, you can fix the error by also adding &mute=1

<iframe class="youtube-video" title="NCBI embedded YouTube video player example" src="https://www.youtube.com/embed/I989pigiJzI?list=PL7dF9e2qSW0aPkIbdB8KfpFLDi0U9Ubgx&mute=1?html5=1&enablejsapi=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

Last Reviewed: February 20, 2024