cordova-plugin-opentok icon indicating copy to clipboard operation
cordova-plugin-opentok copied to clipboard

initPublisher creates a publisher object but does not intialize camera

Open ehassaan opened this issue 6 years ago • 10 comments

Bug Report

initPublisher creates a publisher object but does not intialize camera

screenshot_1550508150

Calling the initPublisher('publisherId') function does create a publisher object but it does not initialize the camera and neither asks camera or sound permission. The publisher div shows either black screen or a placeholder image. Surprisingly when using cordova debugger in ionic sample, stepping over the code causes the initPublisher to work perfectly.

Steps to reproduce

Download opentok-ionic-sample (or opentok-cordova-sample) Edit the code to add apiKey, sessionId and token run npm install ionic cordova platform add android ionic cordova run android

cordova-android: "^7.1.4" cordova-plugin-opentok: ^3.4.3 Android Device: Xiamo A1, Android 9 Node LTS v10.15.1 Also tested on emulator Android 7.0

ehassaan avatar Feb 18 '19 16:02 ehassaan

Thanks for filing the issue @HassaanAkbar! I've also answered the question here: https://stackoverflow.com/questions/54751291/initpublisher-creates-a-publisher-object-but-does-not-initialize-camera/54755174#54755174

I'll update you as we make progress 😄

msach22 avatar Feb 18 '19 20:02 msach22

Thanks @msach22 But i think the issue is not just related to permissions. I just created two buttons. One for initializing publisher and one for connecting session and start publishing. I gave all the permissions from the phone settings. Still the publisher isn't able to initializing. It just shows a placeholder image like before.

screenshot_20190219-031223 I

InitTB is called in constructor.


  initTB() {

    this.session = OT.initSession(this.apiKey, this.sessionId);
    
    OT.addEventListener('exception', function (e) {
      console.log("----EXCEPTION: ", e.message);
      this.error = e.message;
    });

    this.session.on({
      streamCreated: (event) => {
        this.session.subscribe(event.stream, 'subscriber');
        OT.updateViews();
      },
      streamDestroyed: (event) => {
        console.log(`Stream ${event.stream.name} ended because ${event.reason}`);
        OT.updateViews();
      }
    });
  }
 initPublisher() {
    this.publisher = OT.initPublisher('publisherDiv');
  }
  startPublish() {

    this.session.connect(this.token, (error) => {
      console.log("connect error:", error);
      console.log("publisher:", this.publisher);
      this.session.publish(this.publisher);
    });
  }

ehassaan avatar Feb 18 '19 22:02 ehassaan

@HassaanAkbar If you check the Android code - you will see that the native publisher is initialized, but the view is not super-imposed on the DOM element until the publish method is called: https://github.com/opentok/cordova-plugin-opentok/blob/master/src/android/OpenTokAndroidPlugin.java#L243

msach22 avatar Feb 20 '19 16:02 msach22

@msach22 any solution for this issue

alaghusun60 avatar Mar 20 '19 09:03 alaghusun60

@alaghusun60 I have a fix locally for this where the permissions are requested when the initPublisher is called and not when publish is called.

msach22 avatar Mar 20 '19 14:03 msach22

Hi, I found a simple solution change this: for this:

gutierre69 avatar Apr 30 '19 20:04 gutierre69

@gutierre69 using the CDN link would mean that you're using the OpenTok JS SDK and not the Cordova plugin.

msach22 avatar Apr 30 '19 20:04 msach22

@alaghusun60 I have a fix locally for this where the permissions are requested when the initPublisher is called and not when publish is called.

@msach22 Could you please share the local fix code? I managed to make it work the first time. But when I repaeat a call, the camara seems to not initialize.

kerloom avatar May 01 '19 22:05 kerloom

@msach22 Do you have any update?

Thanks!

kerloom avatar May 23 '19 02:05 kerloom

Sorry folks, I'm not longer maintaining this project at this time so I'm unable to help here.

msach22 avatar Aug 02 '19 22:08 msach22