0
votes

I wrote a javascript function that converts a normal Youtube Video URL to an embedded autoplay URL. If I just convert it to a normal NON AUTOPLAY URL it works fine but when I add the autoplay to the end of the URL it does not play in my iframe.

Here is my code that converts the URL:

 function getEmbedVideoURL(originalString)
 {
      var regExp = "watch.*=";
      var autoplay = "?autoplay=1";
      var newstring = originalString.replace(new RegExp(regExp),"embed/");
      newstring += autoplay;
      alert(newstring);
      return newstring;
 }

I have also tried using the string.concat method and it did not work either. Any help is much appreciated. I have been using this URL as an input http://www.youtube.com/watch?v=d1J43_TXly0

1

1 Answers

0
votes

I found the issue. The reason was because in my table i had extra space in the row entries so it was not working.