javascripthtml5-videocontextmenuright-clickdisabled-control

how to disable some options from the right click menu of a video tag like on deeplearning.ai website. Screenshot is attached


I want to know how we can disable some options from the right click menu of a video element on our site like for example - how the developers of deeplearning.ai website disabled some of the menu options when a user right clicks there video.

screenshot of the requirement

Link to example site


Solution

  • You need to use the MediaSource API (sometimes called MSE) to play the video file.

    See this example of a video played via MSE. View its source code or read an article like this one.

    What the website is doing...

    Usually you would export a fragmented MP4 (in a video editor) and then feed the chunks into MSE. It's this chunking process that makes it such that, there is no "one file" to download. Hence the option is disabled.

    In the case of the website, they are using an M3U8 playlist to play chunks of MPEG-TS video files. Since MSE does not support .ts data from the .m3u8 file, a special player (Video-JS) is used to extract and feed chunks into MSE. It can be done manually but the website is preferring to use VideoJS to play their .m3u8 file.