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.
If someone could point me in the right direction I'd greatly appreciate.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With