Youtube Iframe: OnYouTubePlayerAPIReady() Not Called February 01, 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 JugaHow To Make Iframe With Svg "focusable"Difficulty Setting Focus On Newly Created Object In JavascriptA Way To Know When Angular $http Is "requesting" 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 postsHow To Listen Volume Changes Of Youtube Iframe?Youtube Api - Loop Video Between Set Start And End TimesOn A Youtube Video Page, How Do I Check If The Video Is Currently Playing An Ad Or The Actual Video Via Javascript?Finding Open Graph Tags On Youtube Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"
Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"