dimanche 12 septembre 2021

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

Hi Stackoverflow friends, I am beginner in web development. This is a personal project, and my first question in StackOverflow. :-) I hope to explain as clearly as possible...

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.

<?php 

header('Content-type: video/mp4');

$videos  = array(
        'https://gdsit.cdn-immedia.net/video-repository/carini-0281175080.mp4',
        'https://gdsit.cdn-immedia.net/video-repository/funerali-gabriele-conigliaro-7222258160.mp4',
        'https://gdsit.cdn-immedia.net/video-repository/beneficenza-1865095120.mp4',
        'https://gdsit.cdn-immedia.net/video-repository/mercatino-dell-usato-solidale-7035608630.mp4'
    );

$total_video = count($videos);

$total_video--; //array index starting from 0 so decrease 1

$random_index = rand(0, $total_video); //array index 0 to 2

$video_to_play = $videos[$random_index];

echo $video_to_play;

?>

The result is this: -->The Chrome browser or Android don´t show the video

And i have this 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?

Greetings




Aucun commentaire:

Enregistrer un commentaire