注意:它在Chrome浏览器的隐名窗口和其他移动浏览器(如Mozilla)中也能正常工作。它成功地加载了视频数据,但是当我试图播放视频时,它显示了一个错误。使用本地环境(如vs代码等)运行此代码。
这段代码片段在计算机浏览器上正常工作,但是当我在移动Chrome浏览器上使用IP打开相同的页面时,我得到了一个错误,但它也在隐名模式和其他浏览器中工作。
我不知道它为什么会这样,如果任何人都能摆脱它,那将是很有帮助的。
计算机Chrome BrowserWorking精细

移动Chrome浏览器不播放视频

//YouTube embed with YouTube Iframe API
var 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 details
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player("player", {
height: "390",
width: "640",
videoId: "668nUCeBHyY",
//Features
playerVars: {
controls: 0,
rel: 0,
disablekb: 1,
},
});
}
//functions
function 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>
发布于 2022-02-07 14:39:00
发布于 2022-02-12 16:45:43
禁用所有浏览器扩展
我知道这听起来像是一个简单的答案,但试试吧。这种事一直发生在我身上。可能你们中的一个或多个浏览器扩展正在阻止Youtube嵌入的iframe显示更多的安全性或隐私。我知道,Chrome的Blocksi扩展插件嵌入了Youtube。

https://stackoverflow.com/questions/70983683
复制相似问题