如何使用I框架将youtube网页插入HTML网页, 并请我运行一个代码片段以查看其外观。
答案 0 :(得分:1)
有多种方法可以在网页上开始播放视频。
下面可以解决。
setTimeout(function () { $("#myid").modal("hide"); }, 500);
答案 1 :(得分:0)
<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);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
player.setPlaybackRate(2);
event.target.playVideo();
}