0

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?

zcourts
  • 601
  • 5
  • 6
  • 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 Answers1

2

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.)

rwong
  • 16,695
  • 3
  • 33
  • 81
  • 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