Search code examples
phphtmlvideohtml5-videovideo-player

PHP send video stream to custom format default html5 video player



1.) Is it possible to use CSS and modify default html5 video player, when sending mp4 from PHP script? I call link to video from HTML

...
<a href="play.php">My Video
...

and play.php sends back video like this:

<?php
$CTYP= 'video/mp4';
$VidPath = "../MyVideo.mp4";  
header('Content-Type: ' . $CTYP);
$VidFl = fopen($VidPath, "rb");
$VidContent = fread($VidFl, filesize($VidPath));
fclose($VidFl);
echo $VidContent; 
?>

I tried to echo some formatting before sending content, and it didn't work. For the formatting for the player I would just like to add control to speed/slow down video.

2.) Is there a way to jump back to original page after video has finished playing? Thanks


Solution

  • You should consider using the HTML5 "video" tag, so instead link to the video. embed it. you will have the option to hide the default controls and do your own. and videos will have the option for fullscreen view as well (built-in support in the browser).

    <video controls width="250">
        <source src="play.php" type="video/mp4">
        Sorry, your browser doesn't support embedded videos.
    </video>