I want to create video ad that gives you a bonus to game only when you watch the full video. It's supposed to work same as ads on mobile games where you get for example one more try for watching the whole ad. I have code like this:
var video = document.getElementById('video');
var supposedCurrentTime = 0;
video.addEventListener('timeupdate', function() {
if (!video.seeking) {
supposedCurrentTime = video.currentTime;
}
});
video.addEventListener('seeking', function() {
var delta = video.currentTime - supposedCurrentTime;
if (Math.abs(delta) > 0.01) {
video.currentTime = supposedCurrentTime;
}
});
video.addEventListener('ended', function() {
----> giveBonus(); <---- // I want this function to give user bonus, but I don't want user to be able to call this function himself (get bonus without watching video).
});
I want to give bonus only when full video was watched, so I want to prevent user from calling the giveBonus() function himself or faking that he watched the video if he didn't or getting the bonus without watching the video in some other way. Is there a way to do this?
Sorry for my english and thanks for your help!
Aucun commentaire:
Enregistrer un commentaire