0

I was trying to follow Janus videoroom example but I have an error when calling attach on janus instance:

janus.nojquery.js:681 200: Could not parse response, error: ReferenceError: adapter is not defined, text: {
   "janus": "success",
   "transaction": "Y0WiAA79RQ9l",
   "data": {
      "id": 7571647455176760
   }
}

This doesnt allow me to get videoroom pluginHandle so I cant communicate with plugin.

below is codesnipet that I try to make work:

Janus.init({debug: "all", callback: function() {
    const janusInstance = new Janus(
      {
        server: 'http://localhost:1414/janus',
        success: function () {
          console.log('connected', janusInstance)
          janusInstance.attach(
            {
              plugin: "janus.plugin.videoroom",
              opaqueId: Janus.randomString(12),
              success: function (pluginHandle) {
                console.log('plugin handle received', pluginHandle)
              },
              onmessage: function(msg, jsep) {
                console.log(msg, jsep)
              },
              onlocalstream: function(stream) {
                console.log(stream)
              },
              error: function (error) {
                console.error(error)
              }
            }
          )
        },
        error: function(error) {
          console.error(error)
        }
      })
}})

as Janus server I use served locally docker image: https://github.com/canyanio/janus-gateway-docker

any help will be highly appreciated. Thank you!

31415926
  • 3,811
  • 7
  • 47
  • 78

1 Answers1

0

If I correctly understand your problem - you need to paste adapter on initialization Janus. But before that - import your adapter into component or install it in a project (write a src=".../example-adapter.js" ), for example:

import adapter from "webrtc-adapter" - choose necessary directory or library to your adapter.

Then add a field "dependencies" to Janus.init({}) in this way:

Janus.init({
   debug: true,
   dependencies: Janus.useDefaultDependencies({ adapter: adapter }),
   callback: function() {},
 })
Steven
  • 1,996
  • 3
  • 22
  • 33
Alexandr
  • 1
  • 3
  • Damn...i pushed the wrong chose one on suggested edits, my bad. Please sorry guys, can you repeat this voting please - i will chose correctly)) Im just a new guy on the stack, sorry again) – Alexandr Jul 28 '23 at 13:15