Enable/Disable fullscreen option video.js HTML5

fullscreen, html, html5-video, javascript, video

Solution

Current version of video-js (6.x.x) supports disabling of fullscreen button also by `fullscreenToggle` option. You can simply set it during init of the player like this:

videojs("my-video", {
    controlBar: {
      fullscreenToggle: false
    }
});

However, I observed that it doesn't mean that you are not able to enter fullscreen by hand gesture on mobile devices. (For example reverse pinch on iPad - two fingers on the screen and moving them apart). That's another story - I'm dealing with it by listening for `fullscreenchange` event and checking `isFullscreen()` state of the player (fullscreenchange event triggers on opening but on closing of the fullscreen as well), if it's in fullscreen then I'm calling `exitFullscreen()` function. Just like this:

videojs("my-video",{controlBar: {fullscreenToggle: false}}).ready(function(){
    let myPlayer = this;
    myPlayer.on("fullscreenchange", function(){
        if(myPlayer.isFullscreen()){
            myPlayer.exitFullscreen();
        }
    });
});

Problem

How can I enable/disable the fullscreen option of one video from my post tag HTML in Wordpress? I'm using Video.js. I would not like to make it for ever, just decide which video I want with it or without it, anytime. I tried `AllowFullScreen="true/false"` but it doesn't work.

Original source