How to make video has to to play auto mode and fullscreen in jsp file?

38 Views Asked by At

In my JSP file, I have a YouTube video that needs to be in fullscreen mode. I attempted to implement this in the following code, but it didn't work out. How can I ensure that the video plays in fullscreen mode?

Now, with the following code, the video is playing at the end of the page, not in the center. Can anyone help me out with this?

<script>    
    let player;
    function onYouTubeIframeAPIReady() {
        console.log('onYouTubeIframeAPIReady');
        player = new YT.Player('player', {
            videoId : 'actualId', // Replace with your video ID
            playerVars : {
                'autoplay' : 1,
                'controls' : 0,
                'rel' : 0
            },
            events : {
                'onReady' : onPlayerReady,
                'onStateChange' : onPlayerStateChange
            }
        });
    }

    function onPlayerReady(event) {
        event.target.playVideo();
                document.fullscreen;
    }

</script>
<script src="https://www.youtube.com/iframe_api"></script>
   <div class="ifcontainer">
    <div id="player"/>
   </div>
0

There are 0 best solutions below