目前,我们有一个 YouTube iFrame API 设置,其中包含以下(漂亮的样板)代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
var player;
YT.ready(function() {
player = new YT.Player('player', {
videoId: 'iyBaInK2TsI',
width: 200,
height: 200,
events: {
onReady: "onReady",
onStateChange: "onStateChange",
onPlaybackQualityChange: "onPlaybackQualityChange",
onError: "onPlayerError"
},
playerVars: {
fs: 0, // hide fullscreen button by default
playsinline: 1, // make the player not go fullscreen when playing on ios
modestbranding: 1, // hide youtube logo by default - we say 'powered by youtube'
controls: 0, // hide controls by default
showinfo: 0, // hide video title by default
iv_load_policy: 3, // hide annotations by default
rel: 0
}
});
console.log('available quality levels after create = ' + player.getAvailableQualityLevels());
});
// onReady, onStateChange, onPlaybackQualityChange, onPlayerError handlers...
</script>
总而言之,它总是以“中等”质量加载视频。setPlaybackQuality('small')
无论我是使用台式机还是移动设备,通话都不会影响视频质量。
我尝试setPlaybackQuality('small')
在状态变为缓冲或播放时调用 onReady、onStateChange,并在视频播放、未播放或暂停时在 JavaScript 控制台中完全单独调用。
This presents a large issue when users are trying to load the player on a 3G/4G connection. I understand that 3G is being phased out for video streaming but a significant amount of users still operate on 3G connections and the ability to stream at 144p actually makes video tenable on 3G and at 240p makes video tenable on 4G (non-LTE).
When I choose a video with hd720 as a quality option, I can call setPlaybackQuality('hd720') and it works fine.
My specific question is, is there anything in my configuration that would preclude switching to lower quality, and is there a certain set of commands that would work around this limitation and trigger the playback quality actually changing?