提问人:Sourabh Soni 提问时间:11/4/2023 最后编辑:Sourabh Soni 更新时间:11/13/2023 访问量:25
如何计算用户观看视频的总时长
How to calculate the total time user watched a video
问:
我有一个使用 html5 视频播放器播放的视频列表。 在这里,我需要计算用户观看视频的总时间。 我使用 listners 尝试了相同的方法,但这并不准确。 视频持续时间必须以秒为单位计算。
总播放时间 = 0;
video.addEventListener(“播放”, (事件) => {
start = performance.now();
});
`
video.addEventListener(“fullscreenchange”, (event) => {
if (!document.fullscreenElement) {
end = performance.now();
totalPlaytime += end - start;
let end_date_time = moment().format("YYYY-MM-DD H:mm:ss");
let duration = totalPlaytime/1000;
saveMediaLog(start_date_time, end_date_time, duration);//Ajax call to save
}
});`
答: 暂无答案
评论
currentTime
furthest_time_reached
currentTime
furthest_time_reached
totalPlaytime