react-youtube icon indicating copy to clipboard operation
react-youtube copied to clipboard

"autoplay", "loop" and "mute" options don't work

Open barbararcbf12 opened this issue 1 year ago • 4 comments

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,
      },
  }}
/>

barbararcbf12 avatar Mar 19 '24 10:03 barbararcbf12

mute: 1

suksa avatar Apr 09 '24 05:04 suksa

mute works with '1' but loop does not work tho.

chichichunam avatar Apr 11 '24 17:04 chichichunam

Doubt it will get fixed. Repo hasn't been updated in 2 years. Switch to https://github.com/cookpete/react-player

mrchess avatar Apr 21 '24 21:04 mrchess