magento2 – How to use Youtube Player API with jQuery in in Magento 2?

I’m using Magento 2.4 and i’m trying to use Youtube player API with jQuery in Magento 2 .phtml file like this first:

<script>
    require(('jquery'), function($){
        var tag = document.createElement('script');

        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')(0);
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
        

However it is not working at all, then I tried to inject the youtube player api script in requirejs-config.js like this:

var config = {
    map: {
        '*':{
            youTubeIFrame: 'https://www.youtube.com/iframe_api?noext'
        }
    }
};

.phtml file:

<script>
    require(('jquery','youTubeIFrame'), function($,YT){...

but the youtube video does not appear at all

Is there a correct way to load the Youtube Player API with jQuery in MAgento 2 ?