Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube iframe is not working in Chrome browser on Mobile

$
0
0

Note: It also works fine in the incognito window of Chrome browser and other browsers (like Mozilla) on Mobile.

It loads the video data successfully but when I try to play the video it shows me an error.

Run this code using local environment like vs-code etc.

This snippet works on a computer browser properly, but when I open the same page using IP on my mobile Chrome browser, I got an error, but it works in the incognito mode and other browsers too.

I don't know why it is behaving like this, It would be really helpful if anyone can rid of this.

Computer Chrome Browser[Working fine]enter image description here

Mobile Chrome Browser [Not Playing the video]enter image description here

//YouTube embed with YouTube Iframe APIvar tag = document.createElement("script");tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);// YouTube embed player detailsvar player;function onYouTubeIframeAPIReady() {  player = new YT.Player("player", {    height: "390",    width: "640",    videoId: "668nUCeBHyY",    //Features    playerVars: {      controls: 0,      rel: 0,      disablekb: 1,    },  });}//functionsfunction playYT() {  player.playVideo();}function pauseYT() {  player.pauseVideo();}
<div style="pointer-events:none" id="player"></div><br><br><button onclick="playYT()">Play</button><button onclick="pauseYT()">Pause</button>

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>