Search code examples
javascriptvideo.js

VideoJS - Disable auto fullscreen after pressing play button


I switched to VideoJS thanks to ridicilious pricing policy of JWPlayer.

The problem is, when the user starts the video on iOS, it toggles native fullscreen. I want control panel to be available on fullscreen mode but I couldn't manage it yet.

Code:

<video id="tvideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" poster="..." data-setup='{"language":"en", "controls": true,"autoplay": false, "fluid": true, "aspectRatio": "16:9",   "playbackRates": [0.5, 1, 1.5, 2]}'>
   <source src="..." type='video/mp4' label='240p' res='240'/>
   <source src="..." type='video/mp4' label='360p' res='360'/>
   <source src="..." type='video/mp4' label='720p' res='720'/>
   <p class="vjs-no-js">Bu videoyu görüntülemek için lütfen JavaScript'i etkinleştirin.</p>
</video>
<script type="text/javascript">
    var myPlayer = videojs("#tvideo");
    myPlayer.videoJsResolutionSwitcher({
        default: 'high',
        dynamicLabel: true
    });
    myPlayer.persistvolume({
        namespace: 'httpswwwseyredelimcom'
    });
    myPlayer.brand({
        image: "...",
        title: "...",
        destination: "...",
        destinationTarget: "_top"
    });
    myPlayer.ready(function() {
        this.hotkeys({
            volumeStep: 0.1,
            seekStep: 5,
            enableModifiersForNumbers: false
        });
        $(".bAd").detach().appendTo(".video-js");
        $(".plAd").detach().appendTo(".video-js");

        function resizeVideoJS() {
            var containerWidth = $('.video-player').width();
            var videoHeight = Math.round((containerWidth / 16) * 9);
            myPlayer.width(containerWidth).height(videoHeight);
        }
        window.onresize = resizeVideoJS;
        myPlayer.on("ended", function() {
            startNextVideo();
        });
    });
</script>

How could I manage not getting autofull screen and let user have control panels on fullscreen?

Thanks in advance.


Solution

  • To preserve inline playing, add playsinline attribute to video tag.