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

How to disable downloading video?

Open exbucks opened this issue 7 years ago • 11 comments

Hey guys, I just wanted to disable users downloading videos.

<ReactPlayer controls url='http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4' config={{ file: { attributes: { controlsList: 'nodownload' } }}} />

I have found this solution, but it is not a good solution I guess.

I have added controlsList: 'nodownload' to player component but users are still able to download videos.

Here is a screenshot.

screen shot 2019-01-16 at 4 11 44 am

Any idea to disable downloading video?

exbucks avatar Jan 16 '19 09:01 exbucks

Use config.file.attributes with onContextMenu to disable right clicking the video:

class Player extends React.Component {
  render () {
    return (
      <div className='player-wrapper'>
        <ReactPlayer
          url='http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
          playing
          config={{ 
            file: { 
              attributes: {
                onContextMenu: e => e.preventDefault()
              } 
            } 
          }}
        />
      </div>
    )
  }
}

Example: https://jsfiddle.net/32rpued1/

But keep in mind that you can't fully prevent people from downloading videos that you are serving to them.

cookpete avatar Jan 16 '19 13:01 cookpete

This isn't working for me: attributes: { controlsList: 'nodownload' }

danmorley avatar Oct 01 '21 10:10 danmorley

@danmorley What URL are you trying to play and what browser are you using to play it?

cookpete avatar Oct 01 '21 12:10 cookpete

@danmorley What URL are you trying to play and what browser are you using to play it?

Playing a local video file in Chrome

danmorley avatar Oct 01 '21 12:10 danmorley

@danmorley Does this work for you? https://jsfiddle.net/8dsjy4r3/

The download option in the dots menu should be gone.

cookpete avatar Oct 01 '21 13:10 cookpete

My apologies, it's working now, thank you!

danmorley avatar Oct 01 '21 14:10 danmorley

https://video-react.js.org/components/play-toggle/ This can a better option

girishasitsolutions avatar Feb 25 '22 11:02 girishasitsolutions

I want the user not to download the video using IDM or any other extensions is that possible to restrict the user not download.

Krishna-stellarflux avatar Jul 24 '23 03:07 Krishna-stellarflux

I want the user not to download the video using IDM or any other extensions is that possible to restrict the user not download.

That is not possible. If you serve them the file, they can download it one way or another.

hypo-thesis avatar Mar 08 '24 16:03 hypo-thesis

What would be the correct implementation for this in react-player 3.x? Or does it work the same way there?

larswittenberg avatar Oct 06 '25 12:10 larswittenberg

This will require a new prop added controlsList in v3 I believe. PR's welcome, similar to this one https://github.com/cookpete/react-player/pull/2004

luwes avatar Nov 13 '25 20:11 luwes