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.

+2


source to share


5 answers


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.

+4


source


Not sure what you need ... but you can handle the play command (button or download ... however your videos are playing) and attach them to a counter that you store in your database.



We'll need a lot more (a set of codes, a video codec, etc.) before giving more.

+1


source


You can also create a separate table with these columns:

  • VideoId

  • IP address

And add a line every time the user watches the video ...

Then you will calculate unique hours and no duplicate

(Instead of the ip address, you can store the userId if your users are logged in)

+1


source


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

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

0


source


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.

0


source







All Articles