Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit 1b9e916

Browse files
committed
{N} V3 Update
1 parent 3abdaff commit 1b9e916

19 files changed

+325
-391
lines changed

demo/app/main-view-model.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {TNSOTSession, TNSOTPublisher, TNSOTSubscriber} from 'nativescript-opento
88
const M = 23;
99
export class Demo extends Observable {
1010

11-
public _apiKey:string = '45771112';
12-
private _sessionId: string = '1_MX40NTc3MTExMn5-MTQ4NzI1MTY3NTg2NX5JZzFvWHI4NmFLMG1tZnRad2ZwNGl2YTR-UH4';
13-
private _publisherToken: string = 'T1==cGFydG5lcl9pZD00NTc3MTExMiZzaWc9YjY5ODg5ZWNkNWU2YjU0YmY2YjU1ZGFiOGMzZGNlNjQ5OTQ2MjgyZjpzZXNzaW9uX2lkPTFfTVg0ME5UYzNNVEV4TW41LU1UUTROekkxTVRZM05UZzJOWDVKWnpGdldISTRObUZMTUcxdFpuUmFkMlp3TkdsMllUUi1VSDQmY3JlYXRlX3RpbWU9MTQ4NzMzNDkzNSZub25jZT0wLjg3NzA0ODc3ODc1MTA1NTkmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTQ4NzkzOTczNA==';
14-
private _subscriberToken: string = 'T1==cGFydG5lcl9pZD00NTc3MTExMiZzaWc9ZGQ2MDIzNWQ1ZDEyZWM4MTZiMzEzMjE2NDNmNTg5Zjg1ZTQ1MmNkYjpzZXNzaW9uX2lkPTFfTVg0ME5UYzNNVEV4TW41LU1UUTROekkxTVRZM05UZzJOWDVKWnpGdldISTRObUZMTUcxdFpuUmFkMlp3TkdsMllUUi1VSDQmY3JlYXRlX3RpbWU9MTQ4NzMzNDk1OSZub25jZT0wLjg2OTkzODk3NTAzNjUxMDcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTQ4NzkzOTc1OA==';
11+
public _apiKey:string = '45829912';
12+
private _sessionId: string = '1_MX40NTgyOTkxMn5-MTQ5NTE0Mzk3NzI2OX5vdzhEdGtBSm40MW5KWU0rY3RFU3FJNUl-fg';
13+
private _publisherToken: string = 'T1==cGFydG5lcl9pZD00NTgyOTkxMiZzaWc9ZDMxMjcxMjE2MTcwZDRkMDY3ZDMyYzg4YmJkODZlYWQ0M2Q0MmQyMTpzZXNzaW9uX2lkPTFfTVg0ME5UZ3lPVGt4TW41LU1UUTVOVEUwTXprM056STJPWDV2ZHpoRWRHdEJTbTQwTVc1S1dVMHJZM1JGVTNGSk5VbC1mZyZjcmVhdGVfdGltZT0xNDk1MTQ0MDAzJm5vbmNlPTAuMjk1ODExOTA1MTIwMDI0MyZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNDk3NzM2MDAy';
14+
private _subscriberToken: string = 'T1==cGFydG5lcl9pZD00NTgyOTkxMiZzaWc9YTVhNzI5MWZkZWUzZjhhMGRhOWZlMGY2YjYyNzlkYjQ0MWYxOTYwODpzZXNzaW9uX2lkPTFfTVg0ME5UZ3lPVGt4TW41LU1UUTVOVEUwTXprM056STJPWDV2ZHpoRWRHdEJTbTQwTVc1S1dVMHJZM1JGVTNGSk5VbC1mZyZjcmVhdGVfdGltZT0xNDk1MTQ0MDI0Jm5vbmNlPTAuNjk3NTY4MTUzNjA3MTM0MSZyb2xlPXN1YnNjcmliZXImZXhwaXJlX3RpbWU9MTQ5NzczNjAyMw==';
1515
private publisher: TNSOTPublisher;
1616
private subscriber: TNSOTSubscriber;
1717

@@ -28,7 +28,7 @@ export class Demo extends Observable {
2828
});
2929
this.session.events.on('signalReceived',(data:any)=>{
3030
alert("signal received");
31-
console.dump(data);
31+
console.dir(data);
3232
});
3333
}
3434

demo/app/references.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
/// <reference path="../node_modules/tns-core-modules/tns-core-modules.d.ts" /> Enable smart suggestions and completions in Visual Studio Code JavaScript projects.

demo/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"nativescript": {
33
"id": "com.mobileagility.opentok",
44
"tns-ios": {
5-
"version": "2.4.0"
5+
"version": "3.0.0"
66
},
77
"tns-android": {
8-
"version": "2.4.1"
8+
"version": "3.0.0"
99
}
1010
},
1111
"dependencies": {
1212
"nativescript-opentok": "file:..",
13-
"tns-core-modules": "^2.4.0"
13+
"tns-core-modules": "^3.0.0"
1414
},
1515
"devDependencies": {
1616
"babel-traverse": "6.7.6",
@@ -20,7 +20,7 @@
2020
"lazy": "1.0.11",
2121
"nativescript-dev-typescript": "^0.3.2",
2222
"shelljs": "^0.6.0",
23-
"tns-platform-declarations": "^2.4.0",
24-
"typescript": "^2.0.7"
23+
"tns-platform-declarations": "^3.0.0",
24+
"typescript": "^2.2.0"
2525
}
2626
}

demo/tsconfig.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"target": "es5",
5+
"noImplicitAny": false,
6+
"removeComments": true,
7+
"preserveConstEnums": true,
8+
"declaration": true,
9+
"noLib": false,
10+
"noEmitHelpers": true,
511
"experimentalDecorators": true,
6-
"noEmitHelpers": true
12+
"lib": [
13+
"es6",
14+
"dom"
15+
],
16+
"baseUrl": ".",
17+
"paths": {
18+
"*": [
19+
"./node_modules/tns-core-modules/*",
20+
"./node_modules/*"
21+
]
22+
}
723
},
824
"exclude": [
925
"node_modules",

opentok.d.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "nativescript-opentok",
3-
"version": "1.6.8",
3+
"version": "2.0.0",
44
"description": "Integrates OpenTok for NativeScript.",
5-
"main": "opentok.js",
6-
"typings": "./opentok.d.ts",
5+
"main": "opentok",
76
"nativescript": {
87
"platforms": {
9-
"android": "2.4.0",
10-
"ios": "2.4.0"
8+
"android": "3.0.0",
9+
"ios": "3.0.0"
1110
}
1211
},
1312
"scripts": {
@@ -50,15 +49,14 @@
5049
"homepage": "https://github.com/sean-perkins/nativescript-opentok",
5150
"readmeFilename": "README.md",
5251
"devDependencies": {
53-
"es6-promise": "^3.2.1",
54-
"tns-core-modules": "^2.3.0",
55-
"tns-platform-declarations": "^2.3.0",
56-
"typescript": "^2.0.7",
57-
"prompt": "^1.0.0",
58-
"rimraf": "^2.5.0",
59-
"@types/es6-promise": "0.0.28"
52+
"tns-core-modules": "^3.0.0",
53+
"tns-platform-declarations": "^3.0.0",
54+
"typescript": "^2.2.0"
6055
},
6156
"dependencies": {
6257
"nativescript-permissions":"latest"
58+
},
59+
"peerDependencies": {
60+
"tns-core-modules": "3.0.0"
6361
}
6462
}

src/android/publisher.ts

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import * as utils from "utils/utils";
2-
import * as app from 'application';
3-
import {ContentView} from 'ui/content-view'
4-
import {Observable} from "data/observable";
5-
import {TNSOTSession} from "./session";
1+
import * as utils from "tns-core-modules/utils/utils";
2+
import * as app from 'tns-core-modules/application';
3+
import { View, CssProperty, Style } from 'tns-core-modules/ui/core/view'
4+
import { Observable, fromObject } from "tns-core-modules/data/observable";
5+
import { TNSOTSession } from "./session";
6+
import { RENDERSTYLE } from "../common";
67
declare var com: any, android: any;
78
const CameraListener = com.opentok.android.Publisher.CameraListener;
89
const PublisherListener = com.opentok.android.PublisherKit.PublisherListener;
@@ -11,50 +12,52 @@ const BaseVideoRenderer = com.opentok.android.BaseVideoRenderer;
1112
const AbsoluteLayout = android.widget.AbsoluteLayout;
1213
const RelativeLayout = android.widget.RelativeLayout;
1314

14-
export class TNSOTPublisher extends ContentView {
15-
private _android: any;
15+
const renderStyle = new CssProperty<Style, string>({
16+
name: 'renderStyle',
17+
cssName: 'render-style',
18+
defaultValue: 'fill',
19+
valueConverter: (v: RENDERSTYLE) => { return String(v) }
20+
});
21+
22+
export class TNSOTPublisher extends View {
1623
private _publisher: any;
1724
public static toggleVideoEvent = "toggleVideo";
1825
public static toggleAudioEvent = "toggleAudio";
1926
public static cycleCameraEvent;
20-
private _events;
21-
_render_style: any;
22-
27+
private _events: any;
28+
private _renderStyle: any;
29+
public renderStyle: any;
2330
constructor() {
2431
super();
25-
this._events = new Observable();
32+
this._events = fromObject({});
2633
}
2734

2835
get android() {
29-
return this._android;
30-
}
31-
32-
get _nativeView() {
33-
return this._android;
36+
return this.nativeView;
3437
}
3538

36-
public _createUI() {
37-
this._android = new android.widget.LinearLayout(this._context);
39+
public createNativeView() {
40+
return new android.widget.LinearLayout(this._context);
3841
}
3942

4043
publish(session: TNSOTSession, name?: string, cameraResolution?: string, cameraFrameRate?: string) {
4144
const that = new WeakRef(this);
4245
this._publisher = new com.opentok.android.Publisher(
4346
utils.ad.getApplicationContext(),
44-
name ? name : '',
45-
TNSOTPublisher.getCameraResolution(cameraResolution),
47+
name ? name : '',
48+
TNSOTPublisher.getCameraResolution(cameraResolution),
4649
TNSOTPublisher.getCameraFrameRate(cameraFrameRate)
4750
);
4851
let pub = this._publisher.getView();
49-
this._android.addView(pub);
50-
this._publisher.getRenderer().setStyle(com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE, this.render_style);
52+
this.nativeView.addView(pub);
53+
this.renderStyle = this._renderStyle;
5154
this._publisher.setPublisherListener(new PublisherListener({
5255
owner: that.get(),
5356
onError(publisher: any, error: any) {
5457
if (this.owner._events) {
5558
this.owner._events.notify({
5659
eventName: 'didFailWithError',
57-
object: new Observable({
60+
object: fromObject({
5861
publisher: publisher,
5962
error: error
6063
})
@@ -65,7 +68,7 @@ export class TNSOTPublisher extends ContentView {
6568
if (this.owner._events) {
6669
this.owner._events.notify({
6770
eventName: 'streamCreated',
68-
object: new Observable({
71+
object: fromObject({
6972
publisher: publisher,
7073
stream: stream
7174
})
@@ -76,7 +79,7 @@ export class TNSOTPublisher extends ContentView {
7679
if (this.owner._events) {
7780
this.owner._events.notify({
7881
eventName: 'streamDestroyed',
79-
object: new Observable({
82+
object: fromObject({
8083
publisher: publisher,
8184
stream: stream
8285
})
@@ -90,7 +93,7 @@ export class TNSOTPublisher extends ContentView {
9093
if (this.owner._events) {
9194
this.owner._events.notify({
9295
eventName: 'cameraChanged',
93-
object: new Observable({
96+
object: fromObject({
9497
publisher: publisher,
9598
cameraId: newCameraId
9699
})
@@ -100,15 +103,15 @@ export class TNSOTPublisher extends ContentView {
100103
if (this.owner._events) {
101104
this.owner._events.notify({
102105
eventName: 'cameraError',
103-
object: new Observable({
106+
object: fromObject({
104107
publisher: publisher,
105108
error: error
106109
})
107110
});
108111
}
109112
}
110113
}));
111-
session.events.on('sessionDidConnect', (result:any) => {
114+
session.events.on('sessionDidConnect', (result: any) => {
112115
try {
113116
let stream: any = result.object;
114117
session.session.publish(this._publisher);
@@ -149,23 +152,17 @@ export class TNSOTPublisher extends ContentView {
149152
return com.opentok.android.Publisher.CameraCaptureFrameRate.FPS_30;
150153
}
151154

152-
get render_style() {
153-
return this._render_style;
154-
}
155-
156-
set render_style(value: any) {
155+
[renderStyle.setNative](value: any) {
156+
this._renderStyle = value;
157157
switch (value) {
158-
case 'fit':
159-
this._render_style = com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FIT;
160-
break;
161158
case 'fill':
162-
this._render_style = com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FILL;
159+
this._publisher.getRenderer().setStyle(com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE, com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FILL);
163160
break;
164161
case 'scale':
165-
this._render_style = com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE;
162+
this._publisher.getRenderer().setStyle(com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE, com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE);
166163
break;
167164
default:
168-
this._render_style = com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FIT;
165+
this._publisher.getRenderer().setStyle(com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE, com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FIT);
169166
break;
170167
}
171168
}
@@ -174,9 +171,10 @@ export class TNSOTPublisher extends ContentView {
174171
return this._publisher;
175172
}
176173

177-
get events():Observable{
174+
get events(): Observable {
178175
return this._events;
179176
}
177+
180178
toggleCamera() {
181179
this.publishVideo = !this.publishVideo;
182180
}
@@ -218,3 +216,4 @@ export class TNSOTPublisher extends ContentView {
218216
}
219217

220218
}
219+
renderStyle.register(Style);

0 commit comments

Comments
 (0)