I developed a PHP script to show a video at a time from an array of videos URL stored in MySQL. It comes out that all the video show at a time. I need to make it show one-by-one. I understand it has to be something with 'onended' html5 event. But I'm not sure how to use it. Has been googling around last 3 days tried many scripts but still couldn't find the solution.
<?php
$host="localhost";
$username="root";
$password="mypass";
$db_name="mydb";
$con=mysqli_connect($host, $username, $password);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($con, $db_name);
$vid_url = "/files/";
$host = $_SERVER['HTTP_HOST'];
$temp_directory = "/afrison";
$result = mysqli_query($con,"SELECT fileV FROM m_video limit 1");
while($row = mysqli_fetch_assoc($result))
{
$file=explode("/",$row["fileV"]);
$file2=explode('"',$file[1]);
$video = $vid_url.$file2[0];
$extension = explode(".",$video);
$type = $extension[1];
$url = "http://".$host.$temp_directory.$video;
echo "<br>".$file2[0]."<br>".$video."<br>".$type."<br>".$url."
<br>";
?>
<html>
<body>
<video id="myVideo" width="320" height="240" controls autoplay
onended="myFunction()">
<source src="<?php echo $url; ?>" type="video/<?php echo
$type; ?>">
Your browser does not support the video tag.
</video>
<script>
function myFunction() {
window.alert("Some code to play next Video...");
}
</script>
</body>
</html>
<?php
}
?>