E
E
Egor Astreiko2018-06-13 23:13:08
YouTube
Egor Astreiko, 2018-06-13 23:13:08

Why doesn't player.setPlaybackQuality() work?

Hello everyone, here is the js code:

function onYouTubeIframeAPIReady() {
  player = new YT.Player("video", {
    width: "640",
    height: "360",
    videoId: "",
    playerVars: {
      "controls": 0,
      "rel": 0,
      "disablekb": 0,
      "html5": 1, 
      "iv_load_policy": 3,
      "showinfo": 0,
      "fs": 0
    },
    events: {
      onReady: onPlayerReady,
      onStateChange: onPlayerStateChange,
      onPlaybackQualityChange: onPlayerPlaybackQualityChange
    }
  });
}

function onPlayerStateChange(e) {
  if ( e.data == YT.PlayerState.PLAYING || e.data == YT.PlayerState.PAUSED ) {
    // Выбор качества видео
    $(document).find(".youtube-player").find(".form-settings-quality").on("change", "input", function() {
      e.target.setPlaybackQuality($(this).val());
      console.log(player.getPlaybackQuality());
    })
  }
}

Faced the problem that
e.setPlaybackQuality($(this).val()); // Альтернатива player.setPlaybackQuality($(this).val());
does not change the quality of the video being played (
html code of the radio batan in which I try to change the quality of the video:
<div class="wrapper-radio">
<input type="radio" id="quality-01" name="radio-quality" value="small">
<label for="quality-01"><span></span>240p</label>
</div>

Question: What is the reason for this and how can you still let the user change the quality of the video?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chubahu, 2018-08-10
@Egor1324

Youtube blocked forced quality switching in early 2018. The documentation says that "Calling a function does not guarantee a change in playback quality."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question