Can I count the number of times a video is played?

Joined
Aug 22, 2025
Messages
9
Reaction score
0
Hi.

Just a brief query :)

On my html page, I've placed a video element, which is working and plays mp4's.

May I please ask/enquire, each time the video plays, is there anyway of counting the number of times it is played and write this to a database?
Something like a counter, counting how many times the video is clicked/viewed/played?

At present, I've loaded a number of videos into any array, then played back the array in an html page.

Code:
<?
for ($count=0; $count<$new_max; $count++) {?>
     <div class="col-lg-3 col-sm-6">
        <div class="single_new_arrive">
             <div class="sna_img">
                    <!--<img loading="lazy" class="prd_img" src="/library/videos/<?=$new_video[$count]?>" alt="product" /> -->
<!-- $new_videoid[$new_max] = openssl_encrypt($row['video_id'], $ciphering, $encryption_key, $options, $encryption_iv);     -->
                     <video width="240" height="220" controls>
                          <source src="library/videos/<?= $new_video[$count]?>" type="video/mp4">
                          <source src="movie.ogg" type="video/ogg">
                          Your browser does not support the video tag.
                      </video>
                </div>
            <div class="sna_content">
                  <a href="/modules/player/index.php?vid=<?=$new_videoid[$count]?>">
                      <h4><?=$new_title[$count]?></h4>
                   </a>
            </div>
     </div>
</div>
<?}?>

Any suggestions would be welcomed.
Thank You.
 
Joined
Sep 4, 2022
Messages
161
Reaction score
16
the video html tag have few 'events' ready for your goal.

I add 2 links for you :



 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,333
Messages
2,571,383
Members
48,787
Latest member
hypercubes

Latest Threads

Top