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

Autoplay won't start on 2.11.0

Open thepirateboy opened this issue 2 years ago • 6 comments

Current Behavior

The video won't start at all

Expected Behavior

The video should start

Steps to Reproduce

  1. React player 2.11.0
  2. playing = true
  3. loop = true
  4. muted = true

Environment

  • Browser: Brave, Chrome, Safari
  • Operating system: Mac OS

thepirateboy avatar Sep 29 '22 06:09 thepirateboy

If you are using React 18 refer this https://github.com/cookpete/react-player/issues/1508#issuecomment-1264387346

nickchauhan avatar Oct 01 '22 15:10 nickchauhan

What if I'm not on React 18?

Denny966 avatar Oct 12 '22 06:10 Denny966

This worked for me. Could probably remove the volume and muted prop

<ReactPlayer
  url={source.url}
  className="react-player"
  width={width}
  height={height}
  loop={true}
  playing={inView}
  playsinline={true}
  volume={0.5}
  muted={true}
  onReady={(e) => {
    const player = e.getInternalPlayer();
    player.setAttribute('muted', 'true');
  }}
/>

mittnavnermike avatar Dec 20 '22 23:12 mittnavnermike

Documentation for autoplay could be better. We know what HTML5 needs for this to work, but what does ReactPlayer need? Considering it doesn't pass props onto the video node its not really browser standards friendly.

iDVB avatar Mar 10 '23 19:03 iDVB

What type of URL are you trying to play? That’s kind of important. Every third party player that ReactPlayer loads will have its own autoplay nuances, and always be at the mercy of browser autoplay nuances. It’s a losing battle to be honest.

cookpete avatar Mar 11 '23 16:03 cookpete

On Android Phone - Chrome, it will works by just setting props muted={true}, On IOS Safari - you will have to set the playsinline={true} also to force the sound of the video to be muted. If you are using youtube player, by just setting muted to true is just enough

Andy0926 avatar Sep 14 '23 04:09 Andy0926