私はPHPとJWプレーヤーをまったく初めて使用します。
PHPでビデオファイルを読み取り、ブラウザでビデオファイルとして再生する次のコードがあります。
ロードファイル.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 プレーヤーは、次のように直接パスでビデオ ファイルを再生できます。
<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>
ただし、直接パスではなく、loadfile.php でビデオを再生するには、jw プレーヤーが必要です。つまり、ビデオをストリーミングしてphpで読み込んだ後、ビデオをJWプレーヤーに渡す必要があります。これどうやってするの?
アップデート:
JW6を使っています。