Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm working on a flash player that needs to track how long a user plays a video for. In addition, I need to know the user. I can easily do that with a request to the server. What I've thought of so far is sending a request to the server when the user presses play and another when the player stops playing the video. The obvious problem with this approach is that the user can navigate away from the page with out pressing stop, before the video ends.

Are there know approaches you have tried/seen and would recommend?

share|improve this question
    
Maybe use onunload for when they leave the website. I don't use flash, so I'm not entirely sure. But if you can get the time using javascript or something and then send it via ajax maybe by using the onunload event. –  Matt Jul 16 '11 at 17:32

1 Answer 1

up vote 2 down vote accepted

The player can send out heartbeats whenever the video is playing; even if downloading was stopped or has already finished. The heartbeat may contain the approximate position of the video that was played during the last seconds. Then, the user's video watch pattern can be reconstructed from those heartbeat statistics.

According to this SO question, the current position of the video is given by NetStream.time property

There is nothing to prevent or detect if the user has resized the browser to a corner and then open a new browser to do more interesting things.

(Just ideas; I don't know actionscript. Since I'm not able to verify if this works or not, please let me know if this answer is wrong.)

share|improve this answer
    
That's a perfectly reasonable approach. If you run a HTTP sniffer while viewing videos at popular sites you'll exactly this kind of thing in action. –  Perry Jul 16 '11 at 20:12
    
+1 I agree with Perry, pretty good. thanks –  zcourts Jul 17 '11 at 18:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.