How does YouTube calculate the number of views for a video?
I made an internal movie site in .Net. I am playing movie trailers with a jw player. Now I want to know how to calculate the number of views for a video? Is this possible with code? PLease Help.
NBL I don't have a database. I am adding video via xml and the code reads the xml.
A simple approach is to count the number of pages for the page containing the video, not the number of times the video itself has been 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 count the pageloads, I do them during the day to compile statistics over time. Of course, you can use different granularities depending on your specific needs.
Also, I don't particularly like writing to the database with every pageload, so I have a class I wrote that caches hits and then writes them after every hundred hits or so.
In this class, I also store each user's IP address. This allows me to search for duplicate pageloads. The next task I do in my own hitcounter is sorting people, legit spiders and unwanted bots.
source to share
If you are hosting a video on your page, you should be aware of YouTube's policy for autoplaying these videos for official viewing. If you installed autoplay = true
or equivalent in the player , then the number of YouTube views does not increase. This means that you can copy spam pages with an automatic increase in the number of views. The user has to click on the play button and watch all, or at least most, of the video in order to count it as a presentation.
source to share