@
@
@Sivard2014-02-14 11:32:49
YouTube
@Sivard, 2014-02-14 11:32:49

How to create a counter for youtube videos on your website?

Good afternoon.
Faced the task of creating a counter for youtube videos, which are located on my website.
For example, the site has 3 videos per page, and when a certain video is launched, an ajax request is made to a certain method.
I can track the very moment of starting and stopping the video, but then it's a dead end.
Reading the youtube api manual didn't help.
Here is the jsfiddle code .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir B., 2014-02-18
@ange007

1. At the start of the video, we record the start time.
2. When you stop the video - see how much has passed since the start.
3. If more than n seconds - send ajax to the php script to increase the value.
Actually purely on js in any way by itself.
Unless individually for each user in LocaleStorage / cookies / similar (it will be stored only until the cache is cleared).
Or do you need something radically different?
The question is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question