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.
NLM YouTube video
Transcript for The National Library of Medicine Welcome Video
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>
NCBI YouTube video -Works with additional code
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