我正在尝试嵌入一个高清YouTube视频,但不管我怎么尝试,它似乎只加载了480p版本。
根据YouTube的说法,嵌入高清视频就像在网址中添加hd=1一样简单:
<iframe src="//www.youtube.com/embed/{videoId}?hd=1" width="960" height="720" frameborder="0" allowfullscreen></iframe>然而,这似乎不起作用,至少在我的iframe实现中是这样
<iframe id="video-player" width="960" height="720" src="//www.youtube.com/embed/{videoId}?enablejsapi=1&autoplay=1&rel=0&modestbranding=1&showinfo=0&showsearch=0" frameborder="0" allowfullscreen></iframe>Javascript API也是如此:
HTML:
<div id="video-player"></div>JS:
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('video-player', {
height: '720',
width: '960',
videoId: '{videoId}',
playerVars: {
'controls': 1,
'autoplay': 1,
'hd': 1
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
player.playVideo();
}发布于 2012-09-18 06:18:19
使用此参数:
vq=hd1080
示例:
<iframe src="https://www.youtube-nocookie.com/embed/SzTdgE04uA8?vq=hd1080" width="853" height="480"></iframe>发布于 2012-04-03 09:33:38
你可以做一个小把戏。通过JS设置质量。这不是保证,但工作在我的网站(ggreplayz.com):
https://developers.google.com/youtube/js_api_reference#Playback_quality
示例:
<iframe id="vid2" style="z-index: 1;" width="853" height="505" src="http://www.youtube.com/embed/<?php echo $vid2Array[0];?>?enablejsapi=1&wmode=transparent&hd=1" frameborder="0" allowfullscreen></iframe>
<script type="text/javascript">
...
function onYouTubePlayerAPIReady() {
player1 = new YT.Player('vid1', {
events: {
'onReady': onPlayerReady1
}
});
...
function onPlayerReady1(event) {
player1.setPlaybackQuality('hd720');
}
...发布于 2012-10-19 08:43:03
https://stackoverflow.com/questions/8057047
复制相似问题