当我使用onYouTubeIframeAPIReady创建iframe播放器API时,将使用http协议创建链接
示例:
// 2. This code loads the IFrame Player API code asynchronously.
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', {
width: '560',
height: '600',
videoId: '7j8B_r4OfAw',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}iframe结果:
<iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="560" height="600" src="http://www.youtube.com/embed/7j8B_r4OfAw?enablejsapi=1"></iframe>有谁知道如何使用https协议创建视频吗?需要在平台上安装api。
请建议一下!
发布于 2013-07-15 20:25:40
如果直接在html中创建iframe元素,而不是使用以后会替换的div,则可以指定https。如果需要,您可以动态创建iframe标记。看看this section的底部,它详细说明了如何做到这一点。
注意-即使你通过https加载播放器,实际的视频流也可能是通过http提供的。这似乎在Chrome中导致了一个混合模式的警告,尽管其他浏览器没有(根据我去年的经验,它可能已经改变了)。参见this official blog post,它解释了播放器可以通过https加载,但警告说视频仍然不一定以这种方式提供。
https://stackoverflow.com/questions/17647455
复制相似问题