Skip to content
Advertisement

PHP: How to play random mp4 videos in static url .php

I have a code in PHP language hosted in webcindario.com (free hosting), that shows on click a video randomly. But it works ONLY in VLC Player for Windows.

JavaScript

The result is that the Chrome browser or Android don´t show the video: The Chrome browser or Android don´t show the video

And I have these questions:

  1. Is there a way to get the code to work on Android devices and programs like Kodi or Tivimate, inside .m3u lists?

  2. Can it be done in such a way that you don’t have to click every time, as if it were a 24/7 video in loop? (on Android and Windows, of course) Is that possible?

Advertisement

Answer

To display video and several browsers you should use HTML5 so for example:

JavaScript

1 This will play on most browsers!

You can see I added “autoplay” to the top of the video element! This will run on most browsers and android / mac – you should know that autoplay on chrome android is usually blocked.

Use some css, to move it around!

2 Since you are using this in php to receive the next video name the page needs reloading so add to the top this :

JavaScript

This will cause the page to reload every 20 second – change the time for 180 sec for 3 mins for example … 🙂

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement