JW Player从php读取

far*_*eed 2 php jwplayer

我是PHP和JW播放器的新手.

我有以下代码在php中读取视频文件并在浏览器中将其作为视频文件播放:

loadfile.php

<?php
    header("pragma : no-cache");
    header("Expires: Thu, 19 Nov 1981 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: videos/testvid.mp4");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize("videos/testvid.mp4"));
    readfile("videos/testvid.mp4");
?>
Run Code Online (Sandbox Code Playgroud)

JW播放器可以通过直接路径播放视频文件,如下所示:

<div id="mediaplayer"></div>
        <script type="text/javascript">
            jwplayer('mediaplayer').setup({
                'flashplayer': 'jwplayer/jwplayer.swf',
                'file': 'videos/testvid.mp4',
                'id': 'playerID',
                'width': '480',
                'height': '320'
            });
        </script>
Run Code Online (Sandbox Code Playgroud)

但是,我需要jw播放器在loadfile.php中播放视频而不是直接路径.换句话说,我需要在流式传输后将视频传递给JW播放器并在php中读取.我怎样才能做到这一点?

更新:

我正在使用JW 6

ema*_*aun 5

既然你在这个代码行下使用JW6:

'id': 'playerID',
Run Code Online (Sandbox Code Playgroud)

添加以下内容:

'type': 'mp4',
Run Code Online (Sandbox Code Playgroud)

现在,php文件应该作为播放器的"文件"变量,就好了.