最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - JW Player can not play m3u8 stream? - Stack Overflow

matteradmin4PV0评论

with check this example, .html , I tried the example myself, There is my code:

<html>
<head>

    <script type="text/javascript" src="jwplayer.js"></script>
    <script src=".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

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

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

<html>
<head>

    <script type="text/javascript" src="jwplayer.js"></script>
    <script src="http://ajax.googleapis./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

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

Share Improve this question asked May 24, 2012 at 8:58 whywhy 24.9k30 gold badges98 silver badges146 bronze badges 1
  • This has been asked since but apparently it also got no quality answers: stackoverflow./questions/14988021/… – chiliNUT Commented May 2, 2020 at 7:05
Add a ment  | 

2 Answers 2

Reset to default 1

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

http://www.jwplayer./pricing/

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

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

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/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/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./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, jwPlayer forum mentions that .m3u8 works only for iOS and Safari. Reference HERE.

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

Post a comment

comment list (0)

  1. No comments so far