Php YouTube嵌入:自动播放1080p?
过去,您可以让嵌入的youtube视频自动播放1080p或其他质量的视频,但是,这不再有效Php YouTube嵌入:自动播放1080p?,php,html,youtube,youtube-api,Php,Html,Youtube,Youtube Api,过去,您可以让嵌入的youtube视频自动播放1080p或其他质量的视频,但是,这不再有效 是否有另一种最新的方法来实现这一点?您可以使用以下iframe API: 使用API,您可以在嵌入式视频准备就绪后指定播放质量,如下例所示: <div id="player"></div> <script> // 2. This code loads the IFrame Player API code asynchronously. var tag
是否有另一种最新的方法来实现这一点?您可以使用以下iframe API: 使用API,您可以在嵌入式视频准备就绪后指定播放质量,如下例所示:
<div id="player"></div>
<script>
// 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', {
height: '390',
width: '640',
videoId: 'INSERT_VIDEO_ID_HERE',
events: {
'onReady': onPlayerReady
}
});
}
// 4. The API will call this function when the video player is ready.
// In this case we set the playback quality to 1080p
function onPlayerReady(event) {
event.target.setPlaybackQuality('hd1080')
}
</script>
您可以使用iframeapi吗?如果可以,请使用player.setPlaybackQualityhd1080。