function downloadYoutube(f) { //$('#player').html('<iframe width="560" height="315" src="https://www.youtube.com/embed/' + f + '" frameborder="0" allowfullscreen></iframe>'); var player; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '360', width: '640', videoId: f, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } function onPlayerReady(event) { event.target.playVideo(); } var done = false; function onPlayerStateChange(event) { if (event.data == YT.PlayerState.PLAYING && !done) { //setTimeout(stopVideo, 6000); done = true; } } function stopVideo() { player.stopVideo(); } $(function(){ downloadYoutube('yitsxFspbDI'); });
funkcja się niewywołuje tak jak by jakiś błąd był w momencie kiedy wszystkie funkcje z youtube api wrzucam do mojej funkcji trzeba to jakoś zreturnować czy coś ? nie mam pojęcia gdzie robię błąd, pomoże ktoś naprowadzi ?

jak nieoplote youtube moją funkcją to działa normalnie, ale potrzebuje to w takiej postaci
