youtube player api, conflict with other javascript eg twitter like button

This code works fine for the youtube iframe api player method. But if I navigate to a page, then click back to the original page, the player does not load. This only happens when I have the javascript code for twitter included. If I take out the twitter js, it works fine, obviously I’d like a twitter like button.

Wonder anyone has any ideas or has found a solution to this problem. Thanks.

youtube code

          // Load the IFrame Player API code asynchronously.
          var tag = document.createElement('script');
          tag.src = "";
          var firstScriptTag = document.getElementsByTagName('script')[0];
          firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

         // Replace the 'ytplayer' element with an <iframe> and
         // YouTube player after the API code downloads.
         var player;

        function onYouTubePlayerAPIReady() {

       player = new YT.Player('youplayer',
       height: '250',
       width: '290',
       events: {
        // call this function when player is ready to use
        'onReady': onPlayerReady

        // load player with first video                
        function onPlayerReady() {
                                 var value1 = $('#1stvideoid').val();


twitter js code looks like this

         !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.