mp4 file through php not playing as html5 video

泪湿孤枕 提交于 2019-12-01 13:59:08

Finally I've found a way to make it work

header("Content-Type: $mediatype");

if ( empty($_SERVER['HTTP_RANGE']) )
{
    header("Content-Length: $filesize");

    $fh = fopen($file, "rb") or die("Could not open file: " .$file);

    # output file
    while(!feof($fh))
    {
         # output file without bandwidth limiting
        echo fread($fh, $filesize);
    }
    fclose($fh);
}
else //violes rfc2616, which requires ignoring  the header if it's invalid
{   
     rangeDownload($file);
}

It is working in direct link of the php file and inside html5 video tag.
But in order to work in Flowplayer (and maybe in other flash/html5 players) you need to add a mp4 extension (eg. view.php?id=XXX&file=type.mp4)

This could have to do with your browser and what plugin it uses to view video files ie) quicktime. The reason it works with Flash is flash handles buffering and time sync and such. It is usually not recommended to let the browser handle playing media files, because it completely depends on the browser configuration and the plugins they have installed.

Some browsers automatically download media files, it's completely configurable by browser and end user.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!