Auto play & loop for Youtube embed code


Normal Youtube embed code looks like follow:

<iframe width="560" height="315" src="https://www.youtube.com/embed/gYPcFyCIvJY" frameborder="0" allowfullscreen></iframe>

The src of iframe is https://www.youtube.com/embed/gYPcFyCIvJY. We need to modify this address as follow to make the embed code auto play & loop:

  • Replace embed by v
  • Add &autoplay=1 for auto play
  • Add &loop=1
  • Add &playlist=video_id

The new source will be https://www.youtube.com/v/gYPcFyCIvJY&autoplay=1&loop=1&playlist=gYPcFyCIvJY

Reference: http://stackoverflow.com/questions/10664158/autostartloop-videos-youtube-videos