opentok / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
MIT License
30 stars 80 forks source link

Publisher connecting as a subscriber without video #157

Closed hash-bud closed 5 years ago

hash-bud commented 5 years ago

Bug Report

When connected from ios( ionic 3, cordova-ios 4.5.5, iphone 6, ios 12.1.2, Cordova Plugin for OpenTok 3.4.4

Current behavior

When you open the playground, Publisher comes under subscribers, but with no audio or video (Just like if a user with subscriber role).

Iphone 6 after clicking start call(Don't mind the white screen. Laptop camera has a tape over it) iphone6_after_start_call

How playground shows the iphone stream

iphone_video stream_not_showing

Steps to reproduce

Connect as a publisher (valid session id and publisher token) this.publisher = OT.initPublisher('publisher-div'); this.session.publish(this.publisher);

Example Project

(If possible, please create an example project here on GitHub.com that exhibits the problematic behaviour, and link to it here in the bug report)

https://github.com/opentok/opentok-ionic-samples

What is the current bug behavior?

When you open the playground, Publisher comes under subscribers, but with no audio or video (Just like if a user with subscriber role).

What is the expected correct behavior?

Should come under subscriber with audio and video(Has given the needed permissions)

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

msach22 commented 5 years ago

@hash-bud Can you please share some more code on how you're running this? Are you seeing an error when you initialize the publisher? Are you calling publish after the session has connected or before?

voxiel commented 5 years ago

@msach22 I'm having the same issue, I'm running the Basic Video Example that is provided.

When I try to join a session in the playground, it joins but as a subscriber without video and audio.

The weird thing is that iOS prompt for camera access and shows video in the app, but is not publishing to the session.

The code is the same as the example:

startCall() {
    this.session = OT.initSession(this.apiKey, this.sessionId);

    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();        
      }
    });

    this.session.connect(this.token, () => {
      this.publisher = OT.initPublisher('publisher');
      this.session.publish(this.publisher);
    });
  }

I would appreciate your help! Thank you!

msach22 commented 5 years ago

@hash-bud Thanks for sharing the code. I think the following comment should fix your issue. Please see: https://github.com/opentok/cordova-plugin-opentok/issues/138#issuecomment-466090152

msach22 commented 5 years ago

I've updated the Ionic samples with the best practices. Please let me know if you have any questions! https://github.com/opentok/opentok-ionic-samples/pull/33