按钮启动和停止嵌入式 YouTube iframe javascipt

const Player = document.getElementById('iframe');  
const PlayBtn = document.getElementById('play');  
const stopBtn = document.getElementById('stop');  
let times = 0, playY;  
const playVideo = PlayBtn.addEventListener( 'click',() => {  
    if(times == 0){  
        var url = new URL(Player.src);  
        var search_params = url.searchParams;  
        search_params.set('autoplay', 1);  
        url.search = search_params.toString();  
  
        playY = url.toString();  
        Player.src = url.toString();  
        times = 1;  
    }  
});  
  
stopBtn.addEventListener( 'click',() => {  
    if(times == 1) {  
        times = 0;  
        var url = new URL(Player.src);  
        var search_params = url.searchParams;  
        search_params.set('autoplay', 0);  
        url.search = search_params.toString();  
        Player.src = url.toString();  
    }  
});