react-youtube
react-youtube copied to clipboard
"autoplay", "loop" and "mute" options don't work
I'm using react-youtube in a ReactJS + TypeScript-project and I use it like below.
I am adding the following opts to my player, but the autoplay, mute and the loop options won't work.
I managed to get the "autoplay" and the "mute" to work by accessing the "InternalPlayer" (see code below) but the loop doesn't work.
<YouTube
ref={youtubePlayerRef}
...
onReady={() => {
youtubePlayerRef.current?.getInternalPlayer().mute();
youtubePlayerRef.current?.getInternalPlayer().playVideo();
youtubePlayerRef.current?.getInternalPlayer().setLoop(true);
}}
opts={{
host: 'https://www.youtube-nocookie.com',
playerVars: {
modestbranding: 1,
loop: 1,
rel: 0,
autoplay: 1,
controls: 0,
mute: 0,
showinfo: 0,
},
}}
/>
mute: 1
mute works with '1' but loop does not work tho.
Doubt it will get fixed. Repo hasn't been updated in 2 years. Switch to https://github.com/cookpete/react-player