0

我需要在 localhost 中广播我的 Steam 以用于开发目的。但是错误出现了。我是媒体服务器的新手。我只想在我的网站上集成 red5pro 媒体服务器以进行一对多广播。我目前正在关注Red5pro Publisher Docs和来自 youtube 的本教程,用于测试 red5pro [从初学者到媒体服务器]。该教程有点过时,但我仍在关注它,因为我没有找到任何其他 red5pro 教程。

我正在使用 python simplehttpserver ("python -m http.server 8000") 来运行本地服务器,如视频教程中所述。

我的html代码->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="video-container">
        <video id="red5pro-publisher"></video>
    </div>
    <script src="lib/red5pro/red5pro-sdk.min.js"></script>
    <script>
        // Create a new instance of the WebRTC publisher.
        var publisher = new red5prosdk.RTCPublisher();

        // Create a view instance based on video element id.
        var view = new red5prosdk.PublisherView('red5pro-publisher');
        view.attachPublisher(publisher);

        // Access user media.
        navigator.getUserMedia({
            audio: true,
            video: true
        }, function (media) {

            // Upon access of user media,
            // 1. Attach the stream to the publisher.
            // 2. Show the stream as preview in view instance.
            publisher.attachStream(media);
            view.preview(media, true);

        }, function (error) {
            console.error(error);
        });

        // Using Chrome/Google TURN/STUN servers.
        var iceServers = [{ urls: 'stun:stun2.l.google.com:19302' }];

        // Initialize
        publisher.init({
            protocol: 'ws',
            host: 'localhost',
            port: 8081,
            app: 'live',
            streamName: 'mystream',
            iceServers: iceServers,
            tcpMuxPolicy: 'negotiate'
        })
            .then(function () {
                // Invoke the publish action
                return publisher.publish();
            })
            .catch(function (error) {
                // A fault occurred while trying to initialize and publish the stream.
                console.error(error);
            });
    </script>
</body>
<!-- WebRTC Shim -->
<!-- <script src="https://webrtc.github.io/adapter/adapter-latest.js"></script> -->
<!-- Exposes `red5prosdk` on the window global. -->
</html>

错误->

  1. 在此处输入图像描述

  2. red5pro-sdk.min.js 第 158 行 -->
    createWebSocket: function(e) { return new WebSocket(e) }

我认为它无法创建 websocket !

4

1 回答 1

0

我不是 HTML5 SDK 方面的专家,但我看到您已将媒体设置和其他几行注释掉;取消注释并重试。还可以查看服务器上的 red5.log 以获取其他线索;任何异常触发都会有所帮助。

于 2021-11-05T13:22:31.063 回答