JW Player无法播放m3u8流?

时间:2012-05-24 08:58:07

标签: javascript jwplayer

查看此示例http://developer.longtailvideo.com/player/branches/adaptive/test/provider.html,我自己尝试了这个示例,有我的代码:

<html>
<head>

    <script type="text/javascript" src="jwplayer.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <title>Provider tests</title>
    <style>
        body { padding: 50px; font: 13px/20px Arial; background: #EEE; }
        form { margin-top: 20px; }
        #player { -webkit-box-shadow: 0 0 5px #999; background: #000; }
        ul { margin-top: 40px; padding: 0 0 0 20px; list-style-type: square; }
    </style>

</head>
<body>

    Test M3U8
    <div id="player">You need Flash to play these tests</div>

    <script type="text/javascript">
        jwplayer("player").setup({
            file: '../m3u8/index.m3u8',
            flashplayer: 'player.swf',
            provider:'adaptiveProvider.swf',
            height: 360,
            width: 640
        });
        function loadStream(url) {
            jwplayer("player").load({file: url,provider: 'adaptiveProvider.swf'});
            jwplayer("player").play();
            return false;
        }

        $(document).ready(function() {
            loadStream('http://localhost/m3u8/index.m3u8');
        });
    </script>
    <ul id="streamlist"></ul>
    <div id="panel"></div>
</body>
</html> 

但是Jw Play无法运作

BTW:我的vlc可以很好地玩http://localhost/m3u8/index.m3u8

2 个答案:

答案 0 :(得分:0)

也许这是一个缺失的!DOCTYPE声明,你没有。

我无法亲自测试,但请尝试此版本,其中还包含基于原始文件的其他修补程序。

<!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" lang="en" xml:lang="en">
  <head>
    <title>Provider tests</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">

    </script>
        <script type="text/javascript" src="jwplayer.js">
    </script>

<style type="text/css">
/*<![CDATA[*/
        body { padding: 50px; font: 13px/20px Arial; background: #EEE; }
        form { margin-top: 20px; }
        #player { -webkit-box-shadow: 0 0 5px #999; background: #000; }
        ul { margin-top: 40px; padding: 0 0 0 20px; list-style-type: square; }
/*]]>*/
</style>

</head>
<body>

Test M3U8

<div id="player">You need Flash to play these tests</div>

<script type="text/javascript">
//<![CDATA[
        jwplayer("player").setup({
            file: '../m3u8/index.m3u8',
            flashplayer: 'player.swf',
            provider:'adaptiveProvider.swf',
            height: 360,
            width: 640
        });
        function loadStream(url) {
            jwplayer("player").load({file: url,provider: 'adaptiveProvider.swf'});
            jwplayer("player").play();
            return false;
        }

//]]>
</script>

<ul id="streamlist"></ul>
<div id="panel"></div>

<script type="text/javascript">
//<![CDATA[
        $(document).ready(function() {
            loadStream('http://localhost/m3u8/index.m3u8');
        });
//]]>
</script>

</body>
</html>

编辑:请注意,您必须在同一个域上才能使用此功能。此外, jwPlayer 论坛提到.m3u8仅适用于 iOS和Safari 。参考HERE

要测试LongTail Video网站随设备提供的有效 .m3u8 流媒体播放网页,请访问此WEBPAGE。使用桌面浏览器时的注意事项!它或 VLC媒体播放器插件可能会因悲伤的脸而崩溃。

答案 1 :(得分:0)

您似乎需要购买高级jwplayer许可才能播放m3u8流。你可以在他们的网站上阅读它

http://www.jwplayer.com/pricing/

它说第三个盒子下的Apple HLS Streams,这就是m3u8的真正含义。