最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Track if a user has watched a video and reward them.? - Stack Overflow

programmeradmin1浏览0评论

I own a incentive site where users plete offers and earn points to purchase items. I'm looking for a way to implement videos into it. A user watches a video all the way through and earns a certain number of points to their account. The site is in PHP and the there is a users table in my database that keeps track of the users points.

Any idea how to check if the user has watched the video?

Thanks!

I own a incentive site where users plete offers and earn points to purchase items. I'm looking for a way to implement videos into it. A user watches a video all the way through and earns a certain number of points to their account. The site is in PHP and the there is a users table in my database that keeps track of the users points.

Any idea how to check if the user has watched the video?

Thanks!

Share Improve this question asked Dec 12, 2011 at 18:41 DeekorDeekor 9,49918 gold badges74 silver badges124 bronze badges 4
  • Are you asking if they looked at the video? or watched the entire video? – D. Rattansingh Commented Dec 12, 2011 at 18:45
  • I think the best you can hope for is that the user played the entire video - who knows if they actually sat and watched it. – Adrian Cornish Commented Dec 12, 2011 at 18:54
  • 1 Just add some very easy facts to the video(s), at different times, and ask the user for them. If he knows the answer, he either must have watched the video or looked up the facts. To prevent the latter, you'll have to generate the video dynamically. – Bergi Commented Dec 12, 2011 at 22:13
  • Looked at the video is most important, because will be generating revenue from the ads that are being played at the beginning the video. I have no preference if they actually watch the content, as long as the revenue es in. – Deekor Commented Dec 12, 2011 at 23:09
Add a ment  | 

4 Answers 4

Reset to default 5

If you just want to catch events in the Youtube embedded player, check out their JS API documentation about Subscribing to events. There's also a list of events you can listen to.

You can go to great lengths in trying to prevent cheating but you still won't catch every last cheater out there since its always possible to cheat the client software.

Stream the video in realtime (where you control the streaming bandwidth so that it's not possible to download the entire video at once), for example from a serverside script, and note the view when the entire video is streamed.

It will always be possible to cheat, though. The user may write a script which just pretends to be a visitor and "view" the video in the background. You can try to prevent this by utilising encryption or obfuscation of some kind, but it's always possible to circumvent since the user can control the clientside as they see fit.

The user may still just mute their speakers and play the video in a minimised window. You can't control this perfectly, although maye you can utilise the blur event in JavaScript to pause the video (in that case, send a signal to the server as well and pause the streaming). They can still leave the puter, though (but that's probably unmon, and your paying clients will certainly know and consider that risk already).

You can use EventListener. You capture the time when video is started. Then you can capture it again in the EventListener "ended" function, after that you calculate the watching time against skipping to end of the video. If video time and watching time is same, you can post to your php that he watched that movie.

The "ended" event should be what you're looking for.

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link type="text/css" href="style.css" rel="stylesheet"/>
    </head>
    <body>

        <video id="movie" src="movie.mov" autoplay="true"></video>

        <script>

            document.getElementById("movie").addEventListener("ended", function(){alert("all done")}, true);

            </script>
    </body>
</html>
发布评论

评论列表(0)

  1. 暂无评论