Youtube Iframe: OnYouTubePlayerAPIReady() Not Called April 14, 2023 Post a Comment I have a page with an iframe which load a youtube video (the src of iframe is modified in runtime). I based on code by Rob W provided in different answers on this topic Solution 1: onYouTubePlayerAPIReady should be on the window object. try: window.onYouTubePlayerAPIReady = function() { alert('called onYouTubePlayerAPIReady'); ytIframeplayer = new YT.Player('browser', { events: { "onStateChange": stopCycle } }); } Copy Solution 2: It seems like you're not closing the functions off correctly. The last } is closing off onYouTubePlayerAPIReady(), not dispose_ytplayer().Baca JugaProxying A Site To Be Able To Wysiwyg Edit In Iframe - How Does It Work?Lazy Load Iframe (delay Src Http Call) With JqueryHow To Run Script Only If Div:contains In An Iframe - Greasemonkey Fixed code: function dispose_ytplayer() { (function(){ var s = document.createElement("script"); s.src = "http://www.youtube.com/player_api"; var before = document.getElementsByTagName("script")[0]; before.parentNode.insertBefore(s, before); })(); alert('called yt_dispose'); var ytIframeplayer; function onYouTubePlayerAPIReady() { alert('called onYouTubePlayerAPIReady'); ytIframeplayer = new YT.Player('browser', { events: { "onStateChange": stopCycle } }); } } Copy Share You may like these postsSocial Media Sites Preventing Other Sites Displaying Their Pages In An IframeYoutube Api PlayVideo Method Doesn't Work On Some Mobile DevicesDetecting A Play Event In Youtube ApiGet Youtube Playlist Index Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"
Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"