'How to Change youtube iframe playback quality with custom controls

I am creaing a youtube custom control player and I want to change video quality through custom dropdown. But there is a big problem youtube iframe deprecated its setPlaybackQuality() now. And and there is no alternate for this function in that documnet

$("#quality").on("change", function (e) {
   

        let data = {
          target:player,
          data:e.target.value
        }
        onPlayerPlaybackQualityChange(data)
      // eventQueue.addEvent("ytplayer://onPlaybackQualityChange?data=" + e.target.value);
     });

below event is fire when we change quality through youtube controls but it did not work when it fire by custom controls

function onPlayerPlaybackQualityChange(playbackQuality) {
    console.log("playback quality function ", playbackQuality)
     onPlaybackQualityChange(playbackQuality);
   }
   function onPlaybackQualityChange(event) {
     console.log("this on called",event)

     eventQueue.addEvent("ytplayer://onPlaybackQualityChange?data=" + event.data);
   }

If any one have solution please share thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source