EliiTryToLearn
EliiTryToLearn

Reputation: 125

Youtube clip auto play and start from beginning when pressed

Is it possible to have an embed YouTube clip on your website that auto-plays when you load the page and when you press the clip it starts from the beginning

<iframe width="420" height="315"
  src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1">
</iframe>

I looked around but I can't find the specific functionality I am looking for.

Upvotes: 1

Views: 829

Answers (1)

Ray
Ray

Reputation: 777

Auto play policy has been changed. ( https://developers.google.com/web/updates/2017/09/autoplay-policy-changes )

If you want to autoplay, add "mute". (Tested in Chrome)

<iframe width="420" height="315"
  src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&mute=1">
</iframe>

And you can control the youtube video with JavaScript.

https://developers.google.com/youtube/iframe_api_reference

It can be implemented variously. I made a sample. (use "seekTo" API) https://jsfiddle.net/raykim2414/uv7b6ty4/15/

Upvotes: 2

Related Questions