tags:

views:

656

answers:

5

I have made an internal movie site in .Net. I play the movie trailers using jw player. Now I want to know how to calculate the number of views for a video? Is it possible through code? PLease help.

NBL I dont have any database. I add the videos through an xml and the code reads the xml.

A: 

The database would have a table for videos, including a Hits column.

When you request the page from the server, the server would execute a stored procedure that adds +1 to the 'Hits' column.

tsilb
i dont have any database. I add the video through an xml.
archana
+1  A: 

Not sure exactly what you need.. but you can handle the play command (button or loading... however your videos are played), and attach that to a counter that you save in your database.

We would need a lot more (code set, video codec and such) before giving more.

IPX Ares
Can you provide me some code links where i can get some clue?
archana
No database? Ummm... well going with @tsilb's post... parse the server log files for hits on each video... though this is going to be really time consuming.You can probably just Google file streaming and RegEx to get this information.I would recommend a database though.
IPX Ares
A: 

You can also create a separate table with these columns :

  • VideoId

  • IP adress

And add a row each times an user watch a video...

Then you will calculate unique watch and not duplicate

(Instead of ip adress you can store userId if your users are registered)

Jmix90
Thankx Jmix.But on what event sgould i carry the above operations?Can we capture the PLay button event in a Windows Media Player or Jw player?
archana
With JW player you can use listener writtent in JavaScript for example which can then make an Ajax Request to a custom page of your choice which will do the job.More infos on this page :http://developer.longtailvideo.com/trac/wiki/FlashApi#Settinglisteners
Jmix90
+3  A: 

A simple approach is to tally the number of pageloads for the page that contains the video, rather than the number of times the video itself is played. First, create a table in your database that contains these fields:

DateTime  date          // date of pageloads -- we'll get to this in a minute
int       videoID       // Unique Identifier for the video loaded
int       count         // Number of pageloads

When I tally pageloads, I do them by day so I can compile statistics over time. Of course, you can use a different granularity depending on your particular needs.

Additionally, I don't particularly like writing to the database with each pageload, so I have a class I've written that caches the hits, then writes them after every hundred hits or so.

In this class, I also retain each user's IP address. This allows me to ferret out duplicate pageloads. A subsequent task, which I'm working through in my own hitcounter, is to triage humans, legitimate spiders and unwelcome bots.

Bob Kaufman
A: 

If you are embedding videos on your page, it's worth being aware of YouTube's policy on the question of autoplaying those videos, in relation to the official viewcount. If in the player you set autoplay = true, or equivalent, then the YouTube view count doesn't increase. This is to counter spammy viewcount auto-augmentation pages. The user has to click on the play button, and watch all, or at least most, of the video to count as a view.

Rafe Lavelle