Sign up ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

So, to know exactly what I'm trying to do, I suppose it's best to look at my code below:

<iframe class="youtube-player" type="text/html" width="280" height="35" src="" frameborder="0"></iframe>

Basically everything works, except the following happens: The video starts playing, it ends at 10 seconds, it loops (restarts), and from that point on it just replays the whole video, instead of stopping at 10 seconds.

Is there any workaround for this? I've really searched all of the web, but I haven't been able to find anything.

PS: I used a blank video, because I don't feel like sharing the video I want to use for this. The 10 seconds is also only for ease of testing.

share|improve this question

2 Answers 2

The problem you are seeing is from the &playlist= tag. What it looks like (to me) is that you were having problems getting 'loop' and 'autoplay' to work together, so you added the 'playlist' tag.

What's happening here is that the API is being tricked into playing the same video over and over by making it think that it's in an infinite playlist of the same video. After the video ends, the next video plays.. which happens to be the same video. However, the 'end' tag was only applied to the first instance of the video.

In order to achieve this, your best bet is to use the YouTube Javascript API as pensan suggested.

share|improve this answer

Take a look at the YouTube JavaScript API. There are functions like player.getCurrentTime() which return the elapsed time of the video. The function player.seekTo(0) will set the player to the beginning of the video.

You could write a small script which resets the player after a specific time (setTimeout) or you could check continuously the getCurrentTime function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.