I want to play a flash video on a webpage, but the source file (*.flv) is outside of webroot.
To be able to access this source file, I gave flashvars a php file reference. This php file will set the headers and return the correct flv file data. I expected this to work, but it is not working.
My response header shows a Content type value of : text/html, whereas if I try to play the video file directly the header is video/x-flv. What might be the problem and any ways to solve it would be great!
My HTML source
<object id=0 type="video/x-flv" data=123.swf width=640 height=360>
<param name="movie" value=123.swf />
<param name="wmode" value="opaque" />
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="quality" value="high" />
<param name="menu" value="true" />
<param name="autoplay" value="false" />
<param name="autoload" value="false" />
<param name="FlashVars" value="flv=media.php" />
</object>
My PHP data in media.php file -
<?php
header("Content-Type: video/x-flv");
readfile("videos/vid1.flv");
?>
However, when I click the video to play, the response headers have a content-type of text/html. I guess, that is the root cause why the video is not playing.
Any help?
Make sure there aren't any tabs/spaces in front of the <?php
tag. This'll cause PHP to give an error when you do header("Content-Type: video/x-flv");
, thus keeping the content type text/html
.
Edit
It might help to end the script with exit()
, to make sure nothing else is ouputted (a tab or space for example, after the trailing ?>
)