Closed tushar-1health closed 7 years ago
in iOS, show error message :
file:///app/tns_modules/nativescript-opentok/src/ios/subscriber.js:18:31: JS ERROR TypeError: session.subscribeError is not a function. (In 'session.subscribeError(this._ios, errorRef)', 'session.subscribeError' is undefined)
Jan 18 20:08:33 Martini com.apple.CoreSimulator.SimDevice.27E82AFF-7324-4916-AF74-F46E44796C3D.launchd_sim[9129] (UIKitApplication:org.nativescript.nstokbox[0x1e32][9604]): Service exited due to signal: Segmentation fault: 11
@tushar-1health are you connecting to the session prior to publishing? Are you integrating this into an existing project or are you running the demo?
The demo has a working example with the publisher/subscriber relationship.
Make sure the token you are generating from TokBox is a publisher token (allows for publishing and subscribing).
I'm trying out the demo app code and replicating in a vanilla hello world ng2 project. Just for poc purposes. The issue is I can see the video publishing and yes I'm connecting to the session. But since I want a iOS facetime sort of application it requires two different tokens for two users (both publishers). But I cannot see the subscribed video, all I'm looking at is a white screen in subscribers pane.
However, when I add this code. Whenever a party joins a session via mobile app or via opentok playground I can see the subscribers pane going all black from white unfortunately no video :(
this.session.events.on('streamCreated', (data) => {
this.subscriber.subscribe(this.session, data.object.get('stream'));
});
Could you please share with some code that will help us with it.
@tushar-1health Make sure you have the correct keys for iOS 10 for permissions. See the referenced Wiki: https://github.com/sean-perkins/nativescript-opentok/wiki/iOS-10-Notice.
As for this repository, feel free to fork and tweak the plugin as necessary. You can submit a PR if you find an issue with the plugin's code. Unfortunately the amount of availability I have to dedicate to these projects are limited, outside of the initial development.
I am not even building for iOS yet. I would love to contribute. However, the issue is, I'm new to Nativescript and this will take time. Just a prototype of basic facetime like app for android will help me understand how opentok and Nativescript works.
@tushar-1health Please try the latest release that Osei submitted a PR for.
@sean-perkins It didn't work. I think I might have narrowed down the issue. I got this while calling subscribe function present in android/session.ts
app/pages/opentok/opentok.component.ts(43,28): error TS2339: Property 'subscribe' does not exist on type 'TNSOTSession'.
This is my piece of code, I'm trying to run this in android
however the TNSOTSession
class being referred to is the one in ios
folder.
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { TextField } from "ui/text-field";
import { View } from "ui/core/view";
import platformModule = require("platform");
import * as dialogs from "ui/dialogs";
import {TNSOTSession, TNSOTPublisher, TNSOTSubscriber} from "nativescript-opentok";
@Component({
selector: 'opentok',
templateUrl: 'pages/opentok/opentok.component.html',
styleUrls: ['pages/opentok/opentok.component.css']
})
export class OpentokComponent implements OnInit {
private _apiKey: string = '45750712';
private _sessionIdRelayed: string = '1_MX40NTc1MDcxMn5-MTQ4NDY2MDg4OTM4Nn50VEdabDVzT2ZwTGNrNm12b0NRNEFsK09-UH4';
private _tokenRelP: string = 'T1==cGFydG5lcl9pZD00NTc1MDcxMiZzaWc9OTJkNmNmNTEwYTgyMWIyMGYzY2IxMDM4OTJkM2Y5NDg2ZmE4Mzc5ZjpzZXNzaW9uX2lkPTFfTVg0ME5UYzFNRGN4TW41LU1UUTRORFkyTURnNE9UTTRObjUwVkVkYWJEVnpUMlp3VEdOck5tMTJiME5STkVGc0swOS1VSDQmY3JlYXRlX3RpbWU9MTQ4NTMzMzc1MyZub25jZT0wLjA5NjMzNzQwMzA1NjEyMDE1JnJvbGU9cHVibGlzaGVyJmV4cGlyZV90aW1lPTE0ODU5Mzg1NTI=';
private session: TNSOTSession;
private token: string;
@ViewChild("publisher") publisher: ElementRef;
@ViewChild("subscriber") subscriber: ElementRef;
constructor() {
this.session = TNSOTSession.initWithApiKeySessionId(this._apiKey, this._sessionIdRelayed);
}
ngOnInit() {
this.session.subscriber = this.subscriber.nativeElement;
this.session.connect(this._tokenRelP);
let publisher:TNSOTPublisher = this.publisher.nativeElement;
publisher.publish(this.session);
this.session.events.on('streamReceived', (data) => {
console.dump(data.object.get('stream'));
// connectionCreated
// this.subscriber.nativeElement.subscribe(this.session);
let subscriber:TNSOTSubscriber = this.subscriber.nativeElement;
console.dump(subscriber);
// subscriber.setVideoActive(true);
this.session.subscribe(subscriber);
console.log('streamCreated');
});
}
}
@triniwiz May be something you can help with too?
EDIT: according to opentok.d.ts
it exports ios and commented that functions should match. However, subscribe function is not available in iOS.
TNSOTSession
does not have the subscribe method anymore (need to remove that for android) since the merge so to subscribe you will need to pass the session and the stream to the subscriber view and since you passed that to your session you can do the following this.session.subscriber.subscribe(this.session,stream)
or you could of done this.subscriber.nativeElement.subscribe(this.session,stream)
hope that clears things up
@triniwiz Thanks. I guess this will work.
However, streamReceived
event has stopped working and it doesn't gets triggered when a new subscriber joins the Session. I just tested it out via playground.
@tushar-1health the streamReceived
works in update coming soon
Thank you @triniwiz and @sean-perkins subscriber and publisher is working perfectly. Thanks to 1c700f2939369dff6e97009bc38dfc0b6d81cd51.
Hello,
This will help as subscribe needs a stream object while subscribing.
However, this too doesn't work I tried and it shows a black screen in subscriber.
@sean-perkins Any help in subscribing? I can see that the device is publishing here https://tokbox.com/developer/tools/playground/ but it does not subscribe, all I can see is a particular black screen.