Jump to content
  • 0

WebRTC play page doesn't play the broadcast


Tahmid Khandokar
 Share

Question

Hello! There,

I've implemented stream publish feature successfully in my Application but I couldn't play the stream. I've followed WebRTC play page creation tutorial which is in the documentation. It plays nothing when I run the html page using a server. Then I logged the object that is passing in WebRTCAdapter callback and found undefined. I also logged inside the play and stop function to see that the functions are called properly or not. Then I found that the functions are called properly. 

I don't know how I can play the stream. Please help me.

Thanks in advance.

here is my play.html

<html>
  <body>
    <video
      width="700"
      height="580"
      id="myRemoteVideo"
      autoplay
      controls
      playsinline
    ></video>
    <br />
    <button type="button" id="start">Start</button>
    <button type="button" id="stop">Stop</button>
  </body>

  <script type="module" lang="javascript">
    import { WebRTCAdaptor } from "./webrtc_adaptor.js";

    let websocketURL = "ws://127.0.0.1:5080/demo/websocket";

    let mediaConstraints = {
      video: false,
      audio: false,
    };

    let pc_config = {
      iceServers: [
        {
          urls: "stun:stun1.l.google.com:19302",
        },
      ],
    };

    let sdpConstraints = {
      OfferToReceiveAudio: true,
      OfferToReceiveVideo: true,
    };

    var webRTCAdaptor = new WebRTCAdaptor({
      websocket_url: websocketURL,
      mediaConstraints: mediaConstraints,
      peerconnection_config: pc_config,
      sdp_constraints: sdpConstraints,
      remoteVideoId: "myRemoteVideo",
      isPlayMode: true,
      callback: (info, obj) => {
        console.log(info, obj);
        if (info == "play_started") {
          alert("play started");
        } else if (info == "play_finished") {
          alert("play finished");
        } else {
          console.log(info + " notification received");
        }
      },
      callbackError: function (error, message) {
        alert("error callback: " + JSON.stringify(error));
      },
    });

    let streamId = "demo_11663392207702";

    document.getElementById("start").addEventListener("click", startPlaying);
    document.getElementById("stop").addEventListener("click", stopPlaying);

    function startPlaying() {
      webRTCAdaptor.play(streamId, "", "", [], "", "");
      console.log("playing");
    }

    function stopPlaying() {
      webRTCAdaptor.stop(streamId);
      console.log("stopping");
    }
  </script>
</html>

 

  • Like 1
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @Tahmid Khandokar,

I have checked your codes. After I copy this files to under application, here are my changes:

1. I have added js to import code as this:

import {WebRTCAdaptor} from "./js/webrtc_adaptor.js"

2. Please make sure that you have demo application in your environment. Because you are using demo application in your WebSocket URL:

let websocketURL = "ws://127.0.0.1:5080/demo/websocket";

Our default applications are LiveApp or WebRTCAppEE. 

3. Please make sure that you are having broadcasting Stream ID like: 

demo_11663392207702

I have found the above things. If you have an error on console logs, please share us. So that we can give you more detail about your issue.

Best Regards,

Selim

  • Like 1
Link to comment
Share on other sites

  • 0

Hi @Tahmid Khandokar,

What kind of error you've encounter? You should able to see at least WebSocket messages in console logs like as below:

browser_screen_share_supported
testt.html:53 browser_screen_share_supported notification received
testt.html:47 initialized
testt.html:53 initialized notification received

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...