Skip to content

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

@barbararcbf12

Description

@barbararcbf12

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions