Here’s an updated version of my macro using the new substitutions features + thumbnail for lazy loading:
\procedure yt(https,inline-style,class,index,start:"0",end,autoplay:"1",cc_lang_pref,cc_lang_pref,cc_load_policy,color,controls,disablekb,fs,hl,iv_load_policy:"3",modestbranding:"1")
<$let
list={{{[<https>split[list=]nth[2]]}}}
videoId={{{ [<https>split[v=]split[/]last[]split[?]split[&]first[]] }}}
params=`${[<list>is[blank]then[?]else[&]]}$&index=$(index)$&start=$(start)$&end=$(end)$&autoplay=$(autoplay)$&cc_lang_pref=$(cc_lang_pref)$&cc_load_policy=$(cc_load_policy)$&color=$(color)$&controls=$(controls)$&disablekb=$(disablekb)$&fs=$(fs)$&hl=$(hl)$&iv_load_policy=$(iv_load_policy)$&modestbranding=$(modestbranding)$`
embedUrl=`https://www.youtube-nocookie.com/embed/${[<list>!is[blank]addprefix[?listType=playlist&list=]else<videoId>]}$$(params)$`
>
<iframe
title='YouTube video player'
style='width:100%;aspect-ratio:16/9;border:0;max-height:100vh;$(inline-style)$;'
class='video $(class)$'
src='$(embedUrl)$'
allowfullscreen
allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture, web-share'
loading='lazy'
srcdoc=```
<style>
img{width:100%;}
img,span{position:fixed;inset:0;margin:auto;}
span{
height:1lh;
text-align:center;
font:48px/1.5 sans-serif;
color:white;
text-shadow:0 0 0.5em black
}
</style>
<a href='$(embedUrl)$'>
<img
src='https://i.ytimg.com/vi_webp/$(videoId)$/default.webp'
srcset='
https://i.ytimg.com/vi_webp/$(videoId)$/default.webp 500w,
https://i.ytimg.com/vi_webp/$(videoId)$/maxresdefault.webp 1000w'
alt="Video"
>
<span>▶</span>
</a>
```/>
<!-- Doc : https://developers.google.com/youtube/player_parameters -->
\end yt
Demo: Video widget — a non-linear personal web notebook
This should only load the thumbnail, until you click on it. Due to google policy on autoplaying videos, you will need to click twice the first time the video is loaded: Chrome 中的自动播放政策 | Blog | Chrome for Developers
Would be great to add a feature like webvtt-player (umd-mith.github.io)