gpt4 book ai didi

mobile - Youtube Iframe API 不适用于移动设备?

转载 作者:行者123 更新时间:2023-12-02 11:36:43 24 4
gpt4 key购买 nike

我很困惑。 Youtube Iframe API 与标准示例:https://developers.google.com/youtube/iframe_api_reference?hl=de过去一直适用于我的移动设备,现在不再适用了..

我试过这个 fiddle :http://jsfiddle.net/77PJB/3/

<div id="player"></div>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '250',
width: '444',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady
}
});
}

function onPlayerReady(event) {
event.target.playVideo();

}

与 iPad、iPhone 和 Samsung Galaxy Nexus 一起使用。视频无法播放..有什么变化吗?

谢谢

最佳答案

Mobile Considerations

Autoplay and Scripted Playback

The HTML5 element, in certain mobile browsers (such as Chrome and Safari), only allows playback to take place if it's initiated by a user interaction (such as tapping on the player). Here's an excerpt from Apple's documentation:

"Warning: To prevent unsolicited downloads over cellular networks at the user’s expense, embedded media cannot be played automatically in Safari on iOS — the user always initiates playback."

由于此限制,自动播放、playVideo()、loadVideoById() 等函数和参数将无法在所有移动环境中工作。

来自:https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations

自定义“播放”按钮外观的简单解决方法:

有一个覆盖元素 pointer-events: none; pointer-events适用于所有现代 mobile browsers或者只是将视频容器放在按钮上 opacity: 0 .

关于mobile - Youtube Iframe API 不适用于移动设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21109139/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com