javascript JW Player 不能播放 m3u8 流?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10734219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:51:29  来源:igfitidea点击:

JW Player can not play m3u8 stream?

javascriptjwplayer

提问by why

with check this example, http://developer.longtailvideo.com/player/branches/adaptive/test/provider.html, I tried the example myself, There is my code:

检查这个例子,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> 

But the Jw Play can not work

但是Jw Play不能用

BTW: my vlc can play http://localhost/m3u8/index.m3u8well

顺便说一句:我的 vlc 可以玩得http://localhost/m3u8/index.m3u8很好

回答by arttronics

Perhaps it's a missing !DOCTYPE declaration that you don't have.

也许这是您没有的丢失的 !DOCTYPE 声明。

I don't have ability to test this personally, but try this version that also includes other fixes based on the original file.

我没有能力亲自测试这个,但试试这个版本,它也包含基于原始文件的其他修复。

<!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>

EDIT:Note that you will have to be on the same Domain for this to work. Also, jwPlayerforum mentions that .m3u8works only for iOS and Safari. Reference HERE.

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

To test a valid .m3u8streaming playback webpage provided by LongTail Video website with your device, access this WEBPAGE. Caution when using desktop browser! It or VLC Media Player Pluginmight crash with a sad face.

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

回答by whotheman

It seems you need to buy premium jwplayer license in order to play m3u8 streams. You can read about it in their site

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

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

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

It says Apple HLS Streams under the third box, which is what m3u8 really is.

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