I'm having some trouble setting the quality settings on a video via the Youtube iFrame API. This is my code:
var player;
player = new YT.Player('player', {
height: '490',
width: '725',
videoId: yturl,
/* setPlaybackQuality: 'hd720', <-- DOES NOT WORK */
/* suggestedQuality: 'hd720', <-- DOES NOT WORK */
events: {
'onReady': onPlayerReady
}
});
function onPlayerReady(event) {
player.setPlaybackQuality('hd720'); // <-- DOES NOT WORK
event.target.setPlaybackQuality('hd720'); // <-- DOES NOT WORK
player.setVolume(100); // <-- DOES WORK
console.log(player.getPlaybackQuality()); // <-- Prints 'small' to console
event.target.playVideo();
}
The funny thing is that my call to player.setPlaybackQuality
or event.target.setPlaybackQuality
doesn't give any errors. It just looks as if the player ignores it. A call to, say, player.setSuggestedQuality
(a function that doesn't exist) throws an error as expected.
I've tried all the valid string parameters as outlined in the API reference ('medium', 'large', 'hd720' etc). None of them work.
Anyone have any suggestions to how I'm supposed to set this property?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…