├── .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 | [![npm](https://img.shields.io/npm/v/nativescript-opentok.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/nativescript-opentok) 4 | [![npm](https://img.shields.io/npm/dt/nativescript-opentok.svg?maxAge=2592000?style=plastic)](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 | |![iPhone Image](http://i.imgur.com/tjnfeQ7.png)|![iPad Image](http://i.imgur.com/2Ubjw0W.png)| 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 |