我尝试通过Youtube iframe API插入youtube视频,但现在无法正常显示“发生错误,请稍后重试”。
这是我的代码:
<html>
<head>
<title>test</title>
<script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>
</head>
<body>
<div id="youtube"></div>
<script>
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('youtube', {
videoid: 'UqyT8IEBkvY',
height: '360',
width: '640',
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady() {
console.log("test");
player.playVideo();
player.mute();
}
</script>
</body>
</html>
最佳答案
尝试从HTML YouTube Videos获得的这种简单方法:
<!doctype html>
<html>
<head>
<title>Search</title>
</head>
<body>
<iframe width="420" height="315"
src="https://www.youtube.com/embed/t2ByLmLnYJ8">
</iframe>
<script src="https://apis.google.com/js/client.js"> </script>
</body>
</html>
运行一下,您很快就会在iframe中拥有一个Youtube。如何扩展程序取决于您。
关于youtube - 当我插入iframe youtube视频不起作用时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41014591/