0

I'm currently working on a system for my site that will reward users based on how many minutes of video they have watched. The video player looks like this in HTML:

    <div id="VideoBox">
    <video id="Video" src="placeholder" type="video/mp4" controls autoplay>
    </video>
    </div>

the src="placeholder" is later reassigned the value of a PHP variable. I'm looking for a way to do this in JS/PHP, preferably PHP but JS is also fine.

3ddavies
  • 546
  • 2
  • 19
  • oh i don't know about that, what if i close my eyes? does that still count? anyways, you could get the current time elapsed on the video or the get the time on load on current active tab – Kevin Jul 24 '18 at 01:37
  • at first I thought that would work, but I don't want the user to be able to get rewarded if they just use the time bar thing to skip to the end – 3ddavies Jul 24 '18 at 01:38
  • Cant you check when the use hit play? When they hit play send an ajax request to your php. Also on load send another ajax request to get their current mins? Unsure what you are trying to do tho – Deadweight Jul 24 '18 at 01:42
  • 1
    there's no real bulletproof way to get it, you could probably find a js library that tracks eye vision using webcam and get the current scroll level on the browser, but that's by a long shot, but hey, try it. i mean i could just play it and minimize the tab or go to another, it'll be a pain to implement – Kevin Jul 24 '18 at 01:43
  • 1
    @3ddavies: Please check the following question/ answer and see if that is useful, https://stackoverflow.com/questions/37293834/how-to-check-a-user-watched-the-full-video-in-html5-video-player – soccerway Jul 24 '18 at 01:46
  • As previously mentioned you could send an ajax request upon hitting play as well as another one when they pause, stop or when the video has ended. The only gap would be if they navigate away... for which window.unload may help but probably not cover all edge cases, and in case you were not able to figure out when they stopped watching then you will have to normalise the data with a best and approximate guess – andriusain Jul 24 '18 at 01:59

0 Answers0