├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── demo
├── app
│ ├── App_Resources
│ │ ├── Android
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── app.gradle
│ │ │ ├── drawable-hdpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-ldpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── icon.png
│ │ │ └── drawable-nodpi
│ │ │ │ └── splashscreen.9.png
│ │ └── iOS
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-667h@2x.png
│ │ │ ├── Default-736h@3x.png
│ │ │ ├── Default-Landscape-568h@2x.png
│ │ │ ├── Default-Landscape-667h@2x.png
│ │ │ ├── Default-Landscape.png
│ │ │ ├── Default-Landscape@2x.png
│ │ │ ├── Default-Landscape@3x.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ ├── Default.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Icon-Small-50.png
│ │ │ ├── Icon-Small-50@2x.png
│ │ │ ├── Icon-Small.png
│ │ │ ├── Icon-Small@2x.png
│ │ │ ├── Info.plist
│ │ │ ├── icon-40.png
│ │ │ ├── icon-40@2x.png
│ │ │ ├── icon-60.png
│ │ │ ├── icon-60@2x.png
│ │ │ ├── icon-72.png
│ │ │ ├── icon-72@2x.png
│ │ │ ├── icon-76.png
│ │ │ ├── icon-76@2x.png
│ │ │ ├── icon.png
│ │ │ └── icon@2x.png
│ ├── app.css
│ ├── app.ts
│ ├── main-page.ts
│ ├── main-page.xml
│ ├── main-view-model.ts
│ ├── package.json
│ └── references.d.ts
├── package.json
└── tsconfig.json
├── opentok.android.ts
├── opentok.d.ts
├── opentok.ios.d.ts
├── opentok.ios.ts
├── package.json
├── platforms
├── android
│ └── include.gradle
└── ios
│ └── Podfile
├── src
├── android
│ ├── publisher.ts
│ ├── session.ts
│ └── subscriber.ts
├── common.d.ts
├── common.ts
└── ios
│ ├── publisher.ts
│ ├── session.ts
│ └── subscriber.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | *.js
2 | *.js.map
3 | node_modules
4 | .idea
5 | demo/app/*.js
6 | demo/*.d.ts
7 | demo/platforms
8 | demo/node_modules
9 | demo/lib/ios
10 | *.log
11 | *.d.ts
12 | !opentok.d.ts
13 | .vscode
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | demo
2 | *.png
3 | *.jpg
4 | *.log
5 | *.ts
6 | !*.d.ts
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | nativescript-opentok
4 | Copyright (c) 2016, Sean Perkins
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | this software and associated documentation files (the "Software"), to deal in
8 | the Software without restriction, including without limitation the rights to
9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | the Software, and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Nativescript OpenTok
2 |
3 | [](https://www.npmjs.com/package/nativescript-opentok)
4 | [](https://www.npmjs.com/package/nativescript-opentok)
5 |
6 | A Nativescript plugin for the OpenTok iOS and Android SDK.
7 |
8 | OpenTok: https://tokbox.com/developer/
9 |
10 | ## Getting Started
11 |
12 | ### Requirements
13 | - API Key with OpenTok. [Get one here](https://dashboard.tokbox.com/signups/new).
14 | - Ability to generate a valid session id (either through OpenTok account or back-end service)
15 | - Ability to generate a valid token (either through OpenTok account or back-end service)
16 | - Opentok.framework requires projects to be built for only armv7 (device); i386 (simulator), armv6, armv7s, and arm64 are not supported.
17 |
18 | ### Installation
19 | Node Package Manager (NPM)
20 |
21 | - `npm install nativescript-opentok --save`
22 |
23 | ### Integration
24 |
25 | #### Routed Sessions
26 | ##### View
27 | You will first need to import the custom element into the {N} xml view. This can be accomplished by adding this snippet: `xmlns:OT="nativescript-opentok"` to your existing `Page` element tag.
28 |
29 | The basic integration example would include the following declarations for publisher and subscriber. Notice subscriber is any element with `id="subscriber"`.
30 | ```
31 |
32 |
33 | ```
34 |
35 | Next in your page's binding context (a controller, view model, etc.), you will need to import and hook to the OpenTok implementation.
36 |
37 | ```
38 | import {TNSOTSession, TNSOTPublisher, TNSOTSubscriber} from 'nativescript-opentok';
39 |
40 | private _apiKey:string = 'API_KEY';
41 | private _sessionId: string = 'SESSION_ID';
42 | private _token: string = 'TOKEN';
43 |
44 | private publisher: TNSOTPublisher;
45 | private subscriber: TNSOTSubscriber;
46 |
47 | private session: TNSOTSession;
48 |
49 | constructor(private page: Page) {
50 | super();
51 | this.session = TNSOTSession.initWithApiKeySessionId(this._apiKey, this._sessionId);
52 | this.publisher = this.page.getViewById('publisher');
53 | this.subscriber = this.page.getViewById('subscriber');
54 | this.initPublisher();
55 | this.initSubscriber();
56 | }
57 |
58 | initPublisher() {
59 | this.session.connect(this._token);
60 | this.publisher.publish(this.session, '', 'HIGH', '30');
61 | this.publisher.events.on('streamDestroyed', (result) => {
62 | console.log('publisher stream destroyed');
63 | });
64 | }
65 |
66 | initSubscriber() {
67 | this.session.events.on('streamCreated', () => {
68 | this.subscriber.subscribe(this.session);
69 | });
70 | }
71 | ```
72 |
73 | ### Special Articles
74 | - [Overlay UI on the Video Stream](https://github.com/sean-perkins/nativescript-opentok/wiki/Overlay-UI-on-Video-Stream)
75 | - [Angular 2 Integration Guide](https://github.com/sean-perkins/nativescript-opentok/wiki/Angular-2-Integration-Guide)
76 | - [Controlling Resolution and FPS](https://github.com/sean-perkins/nativescript-opentok/wiki/Controlling-Frame-Rate-and-Resolution)
77 | - [Event Hooks](https://github.com/sean-perkins/nativescript-opentok/wiki/Event-Hooks)
78 | - [iOS 10 Notice](https://github.com/sean-perkins/nativescript-opentok/wiki/iOS-10-Notice)
79 |
80 | ### Images
81 | |iPhone|iPad|
82 | |---|---|
83 | |||
84 |
85 | ### Notes
86 | - Publishing is not supported in the Simulator because it does not have access to your webcam. You may see a yellow tea-kettle instead.
87 | - `TNS` stands for **T**elerik **N**ative**S**cript
88 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | // Add your native dependencies here:
2 |
3 | // Uncomment to add recyclerview-v7 dependency
4 | //dependencies {
5 | // compile 'com.android.support:recyclerview-v7:+'
6 | //}
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-736h@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Landscape.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Portrait.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Default@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Icon-Small-50.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Icon-Small-50@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Icon-Small.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/Icon-Small@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | NSCameraUsageDescription
45 | We need your camera to display your feed.
46 | NSMicrophoneUsageDescription
47 | We need your microphone to hear your voice.
48 | UIBackgroundModes
49 | audio
50 |
51 |
52 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-40.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-40@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-60.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-60@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-72.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-72@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-76.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon-76@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/App_Resources/iOS/icon@2x.png
--------------------------------------------------------------------------------
/demo/app/app.css:
--------------------------------------------------------------------------------
1 |
2 | .message {
3 | color: #000;
4 | font-size: 20;
5 | horizontal-align: center;
6 | padding:20;
7 | }
8 |
--------------------------------------------------------------------------------
/demo/app/app.ts:
--------------------------------------------------------------------------------
1 | import * as application from 'application';
2 | application.start({ moduleName: 'main-page' });
3 |
--------------------------------------------------------------------------------
/demo/app/main-page.ts:
--------------------------------------------------------------------------------
1 | import {EventData} from 'data/observable';
2 | import {Page} from 'ui/page';
3 | import {isAndroid, isIOS} from 'platform';
4 |
5 | import {Demo} from './main-view-model';
6 |
7 | export function pageLoaded(args: EventData) {
8 | var page = args.object;
9 | page.bindingContext = new Demo(page);
10 | }
11 |
12 | exports.pageLoaded = pageLoaded;
--------------------------------------------------------------------------------
/demo/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/demo/app/main-view-model.ts:
--------------------------------------------------------------------------------
1 | import * as frame from 'ui/frame';
2 | import {Observable, EventData} from 'data/observable';
3 | import {isAndroid, isIOS} from 'platform';
4 | import * as utils from "utils/utils";
5 | import {Page} from 'ui/page';
6 | import * as dialogs from "ui/dialogs";
7 | import {TNSOTSession, TNSOTPublisher, TNSOTSubscriber} from 'nativescript-opentok';
8 | const M = 23;
9 | export class Demo extends Observable {
10 |
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==';
15 | private publisher: TNSOTPublisher;
16 | private subscriber: TNSOTSubscriber;
17 |
18 | private session: TNSOTSession;
19 |
20 | constructor(private page: Page) {
21 | super();
22 | this.session = TNSOTSession.initWithApiKeySessionId(this._apiKey, this._sessionId);
23 | this.publisher = this.page.getViewById('publisher');
24 | this.subscriber = this.page.getViewById('subscriber');
25 | this.session.subscriber = this.subscriber;
26 | this.publisher.events.on('streamCreated',(data:any)=>{
27 | this.subscriber.subscribe(this.session,data.object.stream);
28 | });
29 | this.session.events.on('signalReceived',(data:any)=>{
30 | alert("signal received");
31 | console.dir(data);
32 | });
33 | }
34 |
35 | publish() {
36 | if(isAndroid){
37 | if(android.os.Build.VERSION.SDK_INT >= M){
38 | TNSOTSession.requestPermission().then((granted)=>{
39 | this.session.connect(this._publisherToken);
40 | this.publisher.publish(this.session, '', 'HIGH', '30');
41 | },(e)=>{
42 | if(e && e["android.permission.CAMERA"]){
43 | dialogs.alert({
44 | title:"Permission Required",
45 | message:"This is required to broadcast your video feed.",
46 | okButtonText:"OK"
47 | })
48 | }
49 |
50 | if(e && e["android.permission.RECORD_AUDIO"]){
51 | dialogs.alert({
52 | title:"Permission Required",
53 | message:"This is required to broadcast your audio feed.",
54 | okButtonText:"OK"
55 | })
56 | }
57 | });
58 | }else{
59 | this.session.connect(this._publisherToken);
60 | this.publisher.publish(this.session, '', 'HIGH', '30');
61 | }
62 | }else{
63 | this.session.connect(this._publisherToken);
64 | this.publisher.publish(this.session, '', 'HIGH', '30');
65 | }
66 |
67 | }
68 |
69 | switchCamera() {
70 | this.publisher.cycleCamera();
71 | }
72 |
73 | toggleVideo() {
74 | this.publisher.toggleCamera()
75 | }
76 |
77 | toggleMute() {
78 | this.publisher.toggleMute();
79 | }
80 |
81 | unpublish() {
82 | this.publisher.unpublish(this.session);
83 | }
84 |
85 | unsubscribe() {
86 | this.subscriber.unsubscribe(this.session);
87 | }
88 |
89 | subscriberConnect(){
90 | this.session.connect(this._subscriberToken);
91 | }
92 |
93 | disconnect() {
94 | this.session.disconnect();
95 | }
96 |
97 | sendSignal() {
98 | this.session.sendSignal('chat', 'hello');
99 | }
100 |
101 | }
--------------------------------------------------------------------------------
/demo/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tns-template-hello-world-ts",
3 | "main": "app.js",
4 | "version": "1.6.0",
5 | "author": {
6 | "name": "Telerik",
7 | "email": "support@telerik.com"
8 | },
9 | "description": "Nativescript hello-world-ts project template",
10 | "license": "Apache-2.0",
11 | "keywords": [
12 | "telerik",
13 | "mobile",
14 | "nativescript",
15 | "{N}",
16 | "tns",
17 | "appbuilder",
18 | "template"
19 | ],
20 | "repository": {
21 | "type": "git",
22 | "url": "git+ssh://git@github.com/NativeScript/template-hello-world-ts.git"
23 | },
24 | "bugs": {
25 | "url": "https://github.com/NativeScript/template-hello-world-ts/issues"
26 | },
27 | "homepage": "https://github.com/NativeScript/template-hello-world-ts",
28 | "android": {
29 | "v8Flags": "--expose_gc"
30 | },
31 | "devDependencies": {
32 | "nativescript-dev-typescript": "^0.3.0"
33 | },
34 | "_id": "tns-template-hello-world-ts@1.6.0",
35 | "_shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8",
36 | "_resolved": "https://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz",
37 | "_from": "tns-template-hello-world-ts@latest",
38 | "scripts": {},
39 | "_npmVersion": "2.14.7",
40 | "_nodeVersion": "4.2.2",
41 | "_npmUser": {
42 | "name": "enchev",
43 | "email": "vladimir.enchev@gmail.com"
44 | },
45 | "dist": {
46 | "shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8",
47 | "tarball": "http://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz"
48 | },
49 | "maintainers": [
50 | {
51 | "name": "enchev",
52 | "email": "vladimir.enchev@gmail.com"
53 | },
54 | {
55 | "name": "erjangavalji",
56 | "email": "erjan.gavalji@gmail.com"
57 | },
58 | {
59 | "name": "fatme",
60 | "email": "hfatme@gmail.com"
61 | },
62 | {
63 | "name": "hdeshev",
64 | "email": "hristo@deshev.com"
65 | },
66 | {
67 | "name": "kerezov",
68 | "email": "d.kerezov@gmail.com"
69 | },
70 | {
71 | "name": "ligaz",
72 | "email": "stefan.dobrev@gmail.com"
73 | },
74 | {
75 | "name": "nsndeck",
76 | "email": "nedyalko.nikolov@telerik.com"
77 | },
78 | {
79 | "name": "rosen-vladimirov",
80 | "email": "rosen.vladimirov.91@gmail.com"
81 | },
82 | {
83 | "name": "sdobrev",
84 | "email": "stefan.dobrev@gmail.com"
85 | },
86 | {
87 | "name": "tailsu",
88 | "email": "tailsu@gmail.com"
89 | },
90 | {
91 | "name": "teobugslayer",
92 | "email": "teobugslayer@gmail.com"
93 | },
94 | {
95 | "name": "valio.stoychev",
96 | "email": "valio.stoychev@gmail.com"
97 | }
98 | ],
99 | "_npmOperationalInternal": {
100 | "host": "packages-5-east.internal.npmjs.com",
101 | "tmp": "tmp/tns-template-hello-world-ts-1.6.0.tgz_1455717516189_0.6427943941671401"
102 | },
103 | "directories": {},
104 | "readme": "ERROR: No README data found!"
105 | }
106 |
--------------------------------------------------------------------------------
/demo/app/references.d.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeamMaestro/nativescript-opentok/2792a1dc86badd845bfe74125127ed87eb06b8a1/demo/app/references.d.ts
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "nativescript": {
3 | "id": "com.mobileagility.opentok",
4 | "tns-ios": {
5 | "version": "3.0.0"
6 | },
7 | "tns-android": {
8 | "version": "3.0.0"
9 | }
10 | },
11 | "dependencies": {
12 | "nativescript-opentok": "file:..",
13 | "tns-core-modules": "^3.0.0"
14 | },
15 | "devDependencies": {
16 | "babel-traverse": "6.7.6",
17 | "babel-types": "6.7.7",
18 | "babylon": "6.7.0",
19 | "filewalker": "0.1.2",
20 | "lazy": "1.0.11",
21 | "nativescript-dev-typescript": "^0.3.2",
22 | "shelljs": "^0.6.0",
23 | "tns-platform-declarations": "^3.0.0",
24 | "typescript": "^2.2.0"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "preserveConstEnums": true,
8 | "declaration": true,
9 | "noLib": false,
10 | "noEmitHelpers": true,
11 | "experimentalDecorators": true,
12 | "lib": [
13 | "es6",
14 | "dom"
15 | ],
16 | "baseUrl": ".",
17 | "paths": {
18 | "*": [
19 | "./node_modules/tns-core-modules/*",
20 | "./node_modules/*"
21 | ]
22 | }
23 | },
24 | "exclude": [
25 | "node_modules",
26 | "platforms"
27 | ]
28 | }
--------------------------------------------------------------------------------
/opentok.android.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Session
3 | */
4 | export * from './src/android/session';
5 | export * from './src/android/publisher';
6 | export * from './src/android/subscriber';
--------------------------------------------------------------------------------
/opentok.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * iOS and Android apis should match.
3 | * It doesn't matter if you export `.ios` or `.android`, either one but only one.
4 | */
5 | export * from './opentok.ios';
6 |
7 | // Export any shared classes, constants, etc.
8 | // export * from './src/common';
--------------------------------------------------------------------------------
/opentok.ios.d.ts:
--------------------------------------------------------------------------------
1 | export * from './src/ios/session';
2 | export * from './src/ios/publisher';
3 | export * from './src/ios/subscriber';
4 |
--------------------------------------------------------------------------------
/opentok.ios.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Session
3 | */
4 | export * from './src/ios/session';
5 | /**
6 | * Publisher
7 | */
8 | export * from './src/ios/publisher';
9 | /**
10 | * Subscriber
11 | */
12 | export * from './src/ios/subscriber';
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-opentok",
3 | "version": "2.0.1",
4 | "description": "Integrates OpenTok for NativeScript.",
5 | "main": "opentok",
6 | "nativescript": {
7 | "platforms": {
8 | "android": "3.0.0",
9 | "ios": "3.0.0"
10 | }
11 | },
12 | "scripts": {
13 | "build": "tsc",
14 | "clean": "rm -rf demo/node_modules demo/lib demo/platforms",
15 | "demo.ios": "npm run preparedemo; cd demo; tns emulate ios",
16 | "demo.android": "npm run preparedemo; cd demo; tns run android",
17 | "ios": "npm run preparedemo; cd demo; tns run ios",
18 | "preparedemo": "npm run build; cd demo; tns plugin remove nativescript-opentok; tns plugin add ..; tns install",
19 | "setup": "npm i; cd demo; npm install; cd ..; npm run build; cd demo; tns plugin add ..; cd .."
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "https://github.com/sean-perkins/nativescript-opentok.git"
24 | },
25 | "keywords": [
26 | "NativeScript",
27 | "OpenTok",
28 | "TokBox",
29 | "JavaScript",
30 | "Android",
31 | "iOS",
32 | "{N}"
33 | ],
34 | "contributors": [
35 | {
36 | "name": "Osei Fortune",
37 | "url": "https://github.com/triniwiz",
38 | "email":"fortune.osei@yahoo.com"
39 | }
40 | ],
41 | "author": {
42 | "name": "Sean Perkins",
43 | "email": "sean@meetmaestro.com"
44 | },
45 | "bugs": {
46 | "url": "https://github.com/sean-perkins/nativescript-opentok/issues"
47 | },
48 | "license": "MIT",
49 | "homepage": "https://github.com/sean-perkins/nativescript-opentok",
50 | "readmeFilename": "README.md",
51 | "devDependencies": {
52 | "tns-core-modules": "^3.0.0",
53 | "tns-platform-declarations": "^3.0.0",
54 | "typescript": "^2.2.0"
55 | },
56 | "dependencies": {
57 | "nativescript-permissions":"latest"
58 | },
59 | "peerDependencies": {
60 | "tns-core-modules": "3.0.0"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/platforms/android/include.gradle:
--------------------------------------------------------------------------------
1 | android {
2 | productFlavors {
3 | "nativescriptopentok" {
4 | dimension "nativescriptopentok"
5 | }
6 |
7 | }
8 | defaultConfig {
9 | ndk {
10 | abiFilters "armeabi", "armeabi-v7a", "x86"
11 | }
12 | }
13 | }
14 | repositories {
15 | maven {
16 | url "http://tokbox.bintray.com/maven"
17 | }
18 | }
19 |
20 |
21 | dependencies {
22 | compile 'com.opentok.android:opentok-android-sdk:2.8.+'
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/platforms/ios/Podfile:
--------------------------------------------------------------------------------
1 | pod 'OpenTok'
--------------------------------------------------------------------------------
/src/android/publisher.ts:
--------------------------------------------------------------------------------
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";
7 | declare var com: any, android: any;
8 | const CameraListener = com.opentok.android.Publisher.CameraListener;
9 | const PublisherListener = com.opentok.android.PublisherKit.PublisherListener;
10 | const Publisher = com.opentok.android.Publisher;
11 | const BaseVideoRenderer = com.opentok.android.BaseVideoRenderer;
12 | const AbsoluteLayout = android.widget.AbsoluteLayout;
13 | const RelativeLayout = android.widget.RelativeLayout;
14 |
15 | const renderStyle = new CssProperty