The basic check is simple, wait for the ended event. It is so simple that you can just download it.
Now, to verify that the user has played the full video , an extensive analysis is required to check whether he will play every second. However, this is not necessary, this user should be enough:
- played as many seconds as video for a long time
- plays until the end of the video
This fragment demonstrates just that. A video will not be marked as fully played if you just skip it to the end. Playing the beginning again and again does not mean that it is fully reproducing:
var video = document.getElementById("video"); var timeStarted = -1; var timePlayed = 0; var duration = 0;
#status span.status { display: none; font-weight: bold; } span.status.complete { color: green; } span.status.incomplete { color: red; } #status.complete span.status.complete { display: inline; } #status.incomplete span.status.incomplete { display: inline; }
<video width="200" controls="true" poster="" id="video"> <source type="video/mp4" src="http://www.w3schools.com/html/mov_bbb.mp4"></source> </video> <div id="status" class="incomplete"> <span>Play status: </span> <span class="status complete">COMPLETE</span> <span class="status incomplete">INCOMPLETE</span> <br /> </div> <div> <span id="played">0</span> seconds out of <span id="duration"></span> seconds. (only updates when the video pauses) </div>
Also om jsFiddle:
https://jsfiddle.net/p56a1r45/2/You can then connect this to google analytics to see how many video games have been played. Simple code from the Google Analytics website :
ga('send', 'event', 'Videos', 'play', 'Video name');
source share