Ever wondered why videos can autoplay on desktop but not on mobile websites when the page loads? The reason lies in the deliberate decision made by operating system developers to disable autoplay on mobile devices, aiming to safeguard users' bandwidth. Since many data providers bill based on data usage, it was deemed beneficial for users to prevent videos from automatically playing upon page load to avoid accruing unnecessary data charges. Therefore, mobile web videos require user interaction, such as clicking, to initiate playback.
Learn more
Uncertain about triggering events within an iFrame...
Curious about why video autoplay doesn't work on mobile devices? Check out this link.
For your situation, consider implementing this solution:
An approach I recently developed for autoplay involves initializing the player with a blank video upon page load:
var player = new YT.Player('yt-media-player', {
height: height,
width: width,
videoId: ''
});
Then, when the lightbox is opened, you can load and play the specific video upon click event:
player.loadVideoById(youtubeId);
player.playVideo();
Find more information here.