问题描述
我对PHP和JW Player完全陌生.
I'm totally new to PHP and JW player.
我有以下代码,该代码读取php中的视频文件并将其作为视频文件在浏览器中播放:
I have the following code that reads a video file in php and plays it as a video file in the browser:
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");
?>
JW播放器可以按如下所示通过直接路径播放视频文件:
JW player can play the video file by direct path as in here:
<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>
但是,我需要jw播放器才能在loadfile.php中而不是通过直接路径来播放视频.换句话说,在流式传输并在php中读取视频后,我需要将视频传递给JW播放器.我怎样才能做到这一点?
However, I need jw player to play the video in loadfile.php and not by direct path. In other words, I need to pass the video to JW player after streaming and reading it in php. How can I do this?
更新:
我正在使用JW 6
推荐答案
由于您正在使用JW6,因此在此代码行下
Since you are using JW6, here, under this line of code:
'id': 'playerID',
添加以下内容:
'type': 'mp4',
现在,php文件应该可以用作播放器的"file"变量,就可以了.
Now, the php file should work as the player's "file" variable, just fine.
这篇关于JW Player从PHP读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!