Skip to content

Commit

Permalink
WAIT
Browse files Browse the repository at this point in the history
  • Loading branch information
Miala-python committed Mar 15, 2024
1 parent 24c84df commit c0c5dac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ function onERR() {
function onYouTubeIframeAPIReady() {
console.log("onYouTubeIframeAPIReady run...");

if (player){
return 'Already created';
}

let playerDivWidth = document.getElementById('player').clientWidth;
player = new YT.Player('player', {
videoId: playlist[id],
Expand Down Expand Up @@ -359,8 +363,8 @@ function waitPlayer() {
try {

if (YT.loaded === 1) {
console.log('YTiframe API ready !');
onYouTubeIframeAPIReady();
console.log('YTiframe API ready ! Wait 1s...');
setTimeout(onYouTubeIframeAPIReady, 1000);
return 'Player created';
} else {
console.log('Wait for YTiframe API...');
Expand Down

0 comments on commit c0c5dac

Please # to comment.