-1

I load my videos through a PHP loop with the link to the videos stored in my database. The videos should launch automatically and play in a loop like gifs. The problem is that the videos load on my PC but not on my mobile. In fact, some load and others don't, and when I refresh, others load and the previous ones don't. It's very random (I have 20 videos)

I've tried forcing them to load with JS but without success or I've done it wrong, I've tried transforming my .mp4 videos into .gif but it doesn't change anything. I've tried using a JS library that creates a custom video player, but the problem persists.

So here's my code if it helps:

<?php foreach ($creations as $index => $creation) { ?>
<div class="mix <?php echo $creation['type']; ?> creations_content open_button-modal"?>">
<?php $fileExtension = strtolower(pathinfo($creation['gif'], PATHINFO_EXTENSION));
<div class="video-creations">
<video autoplay="autoplay" loop="true" muted playsinline defaultmuted>
<source src="./../assets/img/creations/<?php echo $creation['gif']; ?>" type="video/mp4"/></video></div>
<?php } ?>
Arnaud
  • 1
  • 1

1 Answers1

0

One possible solution maybe to add different sources to your videos. This is because different browsers support different streaming formats. Give this a read, it might help you out.

Since you mentioned that you tried using JavaScript, you could try adding some code that would auto play the video once it is fully loaded. Sometimes, the issue might be related to the web server's configuration. So check for any restrictions or settings that might be affecting video playback.

Finally, if possible, consider switching to a Content Delivery Network to deliver your videos. CDNs like Google CDN, Cloudinary, and Akamai can help with faster loading and delivery of video files to different devices.

Natália
  • 34
  • 1