【问题标题】:How can I play a stream file m3u on a website如何在网站上播放流文件 m3u
【发布时间】:2019-08-13 01:29:24
【问题描述】:

我想在我的网站上集成一个网络播放器来播放我的 m3u 流媒体文件。

我在 github 上找到了这个 javascript 文件并试图让它运行。可惜没有成功。

https://github.com/aitorciki/jquery-playlist

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.playlist.js"></script>
</head>

<body>
<script type="text/javascript">
    $(document).ready(function() {
        $('audio').playlistParser({
        proxy: 'proxy.php'
        });
    });
</script>

<audio controls src="http://www.stream.com/stream.m3u">
</body>
</html>

proxy.php 文件:

$url = file_get_contents($_GET["url"]);
echo $url;

还是有完全不同的解决方案?

谢谢

【问题讨论】:

    标签: javascript jquery github m3u


    【解决方案1】:

    播放列表插件似乎适用于 jQuery v3,而不是 jQuery v1。在我修改您的代码以使用 jQuery v3 后,它对我有用

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.playlist.js"></script>
    </head>
    
    <body>
    <script type="text/javascript">
        $(document).ready(function() {
            $('audio').playlistParser({
            proxy: 'proxy.php'
            });
        });
    </script>
    
    <audio controls src="http://www.stream.com/stream.m3u">
    </body>
    </html>
    

    【讨论】:

    • 感谢您的回答。我更改了代码,但它仍然无法正常工作。可能是这些文件与 m3u 文件位于不同的 Web 服务器上吗?如果你运行 sn -p: "message": "TypeError: $(...).playlistParser is not a function",
    猜你喜欢
    • 2012-09-30
    • 2019-03-02
    • 1970-01-01
    • 2011-11-09
    • 1970-01-01
    • 2014-10-31
    • 2012-08-04
    • 2014-12-20
    • 1970-01-01
    相关资源
    最近更新 更多