I use jwplayer to run m3u8 hls for a long time. I just want to create a dynamic m3u8 by php I can get the m3u8 file if I paste the php in browser directly. I also test the m3u8 file in VLC and no problem.
php:
<?php
/*
create m3u8 here
*/
header("Content-type: application/text");
header("Content-Disposition: attachment; filename=index.m3u8");
echo $m3u8file;
?>
The m3u8 file output here:
#EXTM3U
#EXT-X-KEY:METHOD=NONE
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:138497571
#EXTINF:10,
ch22/2013112102/138497571.ts
#EXTINF:10,
ch22/2013112102/138497572.ts
#EXTINF:10,
ch22/2013112102/138497573.ts
#EXTINF:10,
ch22/2013112102/138497574.ts
#EXTINF:10,
ch22/2013112102/138497575.ts
#EXTINF:10,
ch22/2013112102/138497576.ts
#EXTINF:10,
ch22/2013112102/138497577.ts
#EXTINF:10,
ch22/2013112102/138497578.ts
#EXTINF:10,
ch22/2013112102/138497579.ts
#EXTINF:10,
ch22/2013112102/138497580.ts
#EXT-X-ENDLIST
This script will show error in jwplayer "Error loading player: No playable sources found"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>
<script type="text/javascript" src="jwplayer/jwplayer.js"></script>
<script type="text/javascript">jwplayer.key="xxxxxxxxxxxxx";</script>
</head>
<body>
<div class="player_box">
<div id="player_outer">
<div id="player" style="padding-top:100px;"></div>
</div>
<script>
jwplayer("player").setup({
image: "",
file: "http://xxx.xxx.xxx.xxx/tvod/tvod.php?starttime=1384975713&endtime=1384975803",
width: '680',
height: '450',
autostart: true,
});
</script>
</div></body>
</html>
I fix it already. It seems that JWPlayer can only accept m3u8 but not php. I change the URL to http://xxx.xxx.xxx.xxx/tvod/tvod.m3u8?starttime=1384975713&endtime=1384975803. and rewrite m3u8 to php on server. And then it works.