使用php文件而不是直接链接的JWPlayer不起作用

时间:2019-04-16 03:40:07

标签: php apache jwplayer

JWPlayer(v8)可用于直接视频文件链接,但不适用于处理视频文件的php文件。

我被困了好几天而且毫无头绪。我在stackoverflow上检查了类似的帖子,但是没有用。

任何帮助将不胜感激。

  

play.php

<!DOCTYPE html>
    <html>
    <head>
        <script src='jwplayer.js'></script>
        <script>jwplayer.key='YOUR_KEY';</script>
    </head>
    <body>
        <div id="player">Loading the player...</div>
            <script>
            var player = jwplayer('player').setup({
                            type: "mp4",
                            width: "600px",
                            height: "400px",
                            file: "example.mp4", //it works
                            //file: "loadfile.php", => it doesn't work
                            controls: true,
                            allowfullscreen: true,
                            allowscriptaccess: "always",
                            autostart: false,
                    });
            const bumpIt = () => {
                const vol = player.getVolume();
                player.setVolume(vol + 10);
            }
            bumpIt();
            </script>
    </body>
    </html>
  

loadfile.php

<?php
    clearstatcache();
    header("pragma : no-cache");
    header("Expires: Thu, 19 Nov 2020 08:52:00 GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    header("Content-Description: File Transfer");
    header("Content-Type: video/mp4");
    header("Content-Location: example.mp4");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize("example.mp4"));
    readfile("example.mp4");
//    $fp = fopen("example.mp4");
//    $content = fread($fp);
//    echo $content;
//    fclose($fp);
?>

0 个答案:

没有答案