Jump to content
  • 0

Null MediaManager, npm package webrtc_adaptor version 2.4.3


ThibaultOber
 Share

Question

Hello,

I am currently trying to configure a basic player using Angular.

  • I have installed the  @antmedia/webrtc_adaptor plugin -> npm install antmedia/webrtc_adaptor
  • I have added a index.d.ts inside the @types subfolder of npm which allows me to import the dependencies.

this is what the source code looks like:

import { Component, OnInit } from '@angular/core';
import { WebRTCAdaptor } from '@antmedia/webrtc_adaptor';

@Component({
  selector: 'app-player',
  templateUrl: './player.component.html',
  styleUrls: ['./player.component.css']
})
export class PlayerComponent implements OnInit {

  constructor() { }

  private websocketURL = "ws://myserver:5080/LiveApp/websocket";
  private streamId = "test";
  private webRTCAdaptor : any;

  private mediaConstraints = {
    video : false,
    audio : false
  };
        
  private pc_config = {
    'iceServers' : [ {
      'urls' : 'stun:stun1.l.google.com:19302'
    } ]
  };

  private sdpConstraints = {
    OfferToReceiveAudio : true,
    OfferToReceiveVideo : false
  };

  ngOnInit(): void {
    this.createStream();
  }

  createStream() : void
  {

    var adaptor = new WebRTCAdaptor();

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

    this.startPlaying();
  }


  startPlaying() : void {
    this.webRTCAdaptor.play(this.streamId, "", "", [], "", "");
  }
  
   stopPlaying() : void {
    this.webRTCAdaptor.stop(this.streamId);
  }

}

I have the following error:

image.png.5040e1960db48aa4703771df27352b9f.png

The member MediaManager during initialization of WebRTCAdaptor is null.

When i compare my files from npm to the ones provided with the default viewer, some guard have been added. I think that your npm package have not been updated with the most recent changes.

Do you you have a simple solution or should I import all the files manually from the one provided with the default installation ?

image.thumb.png.2159b7d602613ae62393676496ac883c.png

npm source on the left, ant media installation on the right. 

Thank you

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @ThibaultOber

14 hours ago, ThibaultOber said:
private mediaConstraints = {
    video : true,
    audio : true
  };

 

private sdpConstraints = {
    OfferToReceiveAudio : false,
    OfferToReceiveVideo : false
  };

Could you please make these changes as i qouted above, Since you had not enabled Video or Audio for the stream. For video stream you must enable video:true.

Also make the below changes and let us know this work for you.

Thank you

 

Link to comment
Share on other sites

  • 0
8 minutes ago, rahul7827 said:

Hi @ThibaultOber

private sdpConstraints = {
    OfferToReceiveAudio : false,
    OfferToReceiveVideo : false
  };

Could you please make these changes as i qouted above, Since you had not enabled Video or Audio for the stream. For video stream you must enable video:true.

Also make the below changes and let us know this work for you.

Thank you

 

It's my bad, I misunderstood you are only playing not publishing.

  • Like 1
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...