Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ensure users watch whole videos?

Background:

I am developing a web-based teaching program (using Drupal 7, if that matters) that requires users to view educational videos sequentially. I want to make sure they view each video in its entirety before gaining access to the next one. I'm pretty unfamiliar with the YouTube API but I combed through the PHP developer's guide and didn't find any information about how to do this.

I'm open to any reasonable way of accomplishing this. I was thinking that checking whether one or two random timecodes were hit, as well as whether the movie finished playing, would make it reasonably difficult to skip ahead without watching the video.

So to accomplish this I need to figure out two things:

  1. How to let the server know when the video being viewed has hit the selected timecodes, and
  2. How to let the server know when the end of the video has been reached.

If someone could point me in the right direction I'd greatly appreciate.

like image 489
beth Avatar asked May 09 '12 15:05

beth


2 Answers

All you need to do is ping your server when the video player has reached the end (or near the end) of the media file.

You can either write your own (javascript or flash) video player or modify one of the existing ones. This technique won't work with the HTML5 <video> tag.

like image 146
Mahmoud Al-Qudsi Avatar answered Sep 27 '22 23:09

Mahmoud Al-Qudsi


With the youtube api you can 'ping the server'

  function onPlayerStateChange(evt) {       
       if (evt.data == 0){
       alert (player.getDuration())
     }
 }

You can then get the duration of the clip. Further use of the api - timing when the user starts and stops should allow you you to work out the time said user spent viewing the clip. Compare this to the duration and if it matches ( or is close enough) trigger the reward.

https://developers.google.com/youtube/js_api_reference

like image 35
Finbar Tracey Avatar answered Sep 27 '22 23:09

Finbar Tracey