
Embed mp4 with php readfle script
Hi
I'm trying to embed an mp4 video get from yours exemples (bunny.mp4) with php readfile script to protect my videos...
I try different way to do this (headers, embed, cache) but i always get this error : "Error loading player: No playable sources found".
my html here : ingwe.fr/sd/temp/jwp/
my php readfile : ingwe.fr/sd/temp/jwp/test.php (work find on chrome & firefox)
My html embed :
bc.. <html>
<head>
<title>jwp Video</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jwplayer/jwplayer.js" ></script>
<script type="text/javascript">jwplayer.key="rNg+aGOPF80o3PjSgi+qZCXHvoOnffhS8CDBOg==";</script>
</head>
<body style="margin: 0; padding: 0;">
<div id="container">Loading the player...</div>
<script type="text/javascript">
jwplayer("container").setup({
width: 960,
height: 400,
file: 'ingwe/sd/temp/jwp/test.php',
provider: 'http'
});
</script>
</body>
</html>
My php file :
bc.. <?php
$path = "";
$extension = "mp4";
$fileName = "test";
$dirFile = $path . $fileName . "." . $extension;
switch($extension) {
case "flv": $ctype="application/x-shockwave-flash"; break;
case "mp4": $ctype="video/mp4"; break;
case "wmv": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
}
header("Content-type: " . $ctype);
//header("Content-Length: " . filesize($dirFile));
header("Cache-Control: no-cache, no-store, max-age=0, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: Mon, 20 Dec 1980 00:00:00 GMT"); // Date dans le pass
header("Pragma: no-cache");
header("Content-Transfer-Encoding: binary");
header("Content-Description: File Transfer");
// header("Accept-Ranges: bytes");
$fh = fopen($dirFile, "rb") or die("Could not open file: " . $dirFile . "n");
while (!
feof($fh))
{
print(fread($fh, 16384));
}
fclose($fh);
?>
Do you have any solution ?
regards