-
Notifications
You must be signed in to change notification settings - Fork 1k
How Video Count Works
Our video platform classifies videos into two main types:
- Embedded Videos: Videos sourced from other platforms but displayed within our ecosystem.
- Native Videos: Videos that are uploaded, stored, and played directly from our server.
For Native Videos, the viewing metric is pretty straightforward - a view is counted each time the play button is pressed.
For Embedded Videos, it's a bit more complex. Since we don't control the play button directly, we count a view each time a page containing the embedded video is loaded.
Every 30 seconds, our system pings back to log a view. To avoid duplicated views, each ping checks:
- User's ID.
- Session ID (This doesn't work in iframes).
- Client's IP address.
If the video has already been accessed before, instead of logging a new view, we update how much of the video has been viewed.
To see if this mechanism is working, inspect your browser's console log. You should be looking for a request to:
https://yoursite.com/objects/videoAddViewCount.json.php
A successful response will resemble:
{
"seconds_watching_video": 12,
"status": true,
"count": 38,
"videos_id": 42217,
"countHTML": "38",
"resp": 436090,
"users_id": 1,
"session_id": "211f9b7fb59300c08195e02f8296deac"
}
If your response looks different, there might be a hiccup in the view count mechanism.
URL to send request to:
https://yoursite.com/objects/videoAddViewCount.json.php?id=4416¤tTime=0&seconds_watching_video=0&PHPSESSID=ea0ga3uh3ej0hdlplbs706nva3
Payload parameters:
-
PHPSESSID: ea0ga3uh3ej0hdlplbs706nva3 -
id: 4416 -
currentTime: Your current position in the video in seconds. -
seconds_watching_video: Duration of video playback since the last request.
For PHPSESSID, fetch it from the last request's response. For currentTime and seconds_watching_video, update as per your requirements.
var seconds_watching_video_to_send = seconds_watching_video;
seconds_watching_video = 0; // reset the seconds_watching_video
$.ajax({
url: 'https://yoursite.com/objects/videoAddViewCount.json.php',
method: 'POST',
data: {
id: videos_id,
currentTime: currentTime,
seconds_watching_video: seconds_watching_video_to_send
},
success: function(response) {
PHPSESSID = response.session_id;
}
});The Open Source Video Platform Solution
| Service | Description | Link |
|---|---|---|
| 🎯 | Professional Support - Direct assistance from core developers | Contact |
| ☁️ | AVideo CDN - High-performance video delivery network | Pricing |
AVideo Platform © 2024 - Self-hosted video streaming platform
Made with ❤️ by WWBN and the open source community