diff --git a/docs/tb.md b/docs/tb.md index 635b1af9..60a44b16 100644 --- a/docs/tb.md +++ b/docs/tb.md @@ -31,21 +31,36 @@ TB.addEventListener('exception', function(e){ ``` -### OT.initPublisher apiKey:String, [replaceElementId:String], [properties:Object]):Publisher +### OT.initPublisher [replaceElementId:String], [properties:Object]):Publisher Initializes and returns a Publisher object. You can use this Publisher object to test the microphone and camera attached to the Publisher, and then pass this Publisher object to Session.publish() to publish a stream to a session. -You can only create one publisher object. Calling TB.initPublisher() more than once will fail silently. +You can only create one publisher object. Calling `OT.initPublisher()` more than once will fail silently. #### Parameters -* **apikey** (String) — The API key that TokBox provided you when you registered for the OpenTok API. * **replaceElementId** (String) - Optional. The id attribute of the existing DOM element that the Publisher video replaces. If you do not specify a replaceElementId, the application appends a new DOM element to the HTML body. * **properties** (Object) — Optional. This is an optional object that contains the following properties (each of which are optional): + * **audioBitrate** (Number) — The desired bitrate for the published audio, in bits per second. The supported range of values is 6,000 - 510,000. (Invalid values are ignored.) Set this value to enable high-quality audio (or to reduce bandwidth usage with lower-quality audio). + The following are recommended settings: + + * **8,000 - 12,000 for narrowband (NB) speech** + * **16,000 - 20,000 for wideband (WB) speech** + * **28,000 - 40,000 for full-band (FB) speech** + * **48,000 - 64,000 for full-band (FB) music** + + * **The default value is 40,000.** + + * **audioFallbackEnabled** (Boolean) — Whether to turn on audio fallback or not. + + * **audioSource** (Boolean) — If this property is set to false, the audio subsystem will not be initialized for the publisher, and setting the publishAudio property will have no effect. If your application does not require the use of audio, it is recommended to set this property rather than use the publishAudio property, which only temporarily disables the audio track. + * **cameraName** (String) - The preferred camera position. When setting this property, if the change is possible, the publisher will use the camera with the specified position. Valid Inputs: 'Front' or 'Back' + + * **frameRate** (Number) - The desired frame rate, in frames per second, of the video. Valid values are 30, 15, 7, and 1. The published stream will use the closest value supported on the publishing client. The frame rate can differ slightly from the value you set, depending on the device of the client. And the video will only use the desired frame rate if the client configuration supports it. * **height** (Number) — The desired height, in pixels, of the displayed Publisher video stream (default: 198). @@ -57,6 +72,10 @@ You can only create one publisher object. Calling TB.initPublisher() more than o * **publishVideo** (Boolean) — Whether to publish video. + * **resolution** (String) - The desired resolution of the video. The format of the string is "widthxheight", where the width and height are represented in pixels. Valid values are "1280x720", "640x480", and "320x240". The published video will only use the desired resolution if the client configuration supports it. Some devices and clients do not support each of these resolution settings. + + * **videoSource** (Boolean) — If this property is set to false, the video subsystem will not be initialized for the publisher, and setting the publishVideo property will have no effect. If your application does not require the use of video, it is recommended to set this property rather than use the publishVideo property, which only temporarily disables the video track. + #### Returns @@ -65,7 +84,7 @@ You can only create one publisher object. Calling TB.initPublisher() more than o Example Code: ``` -var publisher = OT.initPublisher('1127', 'myPublisherDiv', {name:"HelloWorld"} ); +var publisher = OT.initPublisher('myPublisherDiv', {name:"HelloWorld", audioSource: false } ); ``` diff --git a/package-lock.json b/package-lock.json index a1cfd9b8..34c1c341 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "Cordova-Plugin-OpenTok", - "version": "2.2.0", + "version": "3.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 865a2fff..12a9bd24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Cordova-Plugin-OpenTok", - "version": "2.3.0", + "version": "3.0.0", "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-coffee": "^0.10.1", diff --git a/plugin.xml b/plugin.xml index 2a73ae99..44832e3f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.0.0"> OpenTokCordovaPlugin Add live video streaming to your Cordova Application @@ -12,7 +12,7 @@ - + @@ -26,8 +26,6 @@ - - diff --git a/src/android/com/tokbox/cordova/OpenTokAndroidPlugin.java b/src/android/OpenTokAndroidPlugin.java similarity index 100% rename from src/android/com/tokbox/cordova/OpenTokAndroidPlugin.java rename to src/android/OpenTokAndroidPlugin.java diff --git a/src/android/libs/opentok-android-sdk-2.12.0.aar b/src/android/libs/opentok-android-sdk-2.12.0.aar deleted file mode 100644 index f209febc..00000000 Binary files a/src/android/libs/opentok-android-sdk-2.12.0.aar and /dev/null differ diff --git a/src/android/libs/opentok-android.gradle b/src/android/libs/opentok-android.gradle deleted file mode 100644 index 52109ac6..00000000 --- a/src/android/libs/opentok-android.gradle +++ /dev/null @@ -1,17 +0,0 @@ -repositories { - jcenter() - flatDir { - dirs 'libs' - } -} - -dependencies { - compile(name: 'opentok-android-sdk-2.12.0', ext: 'aar') -} - -android { - packageOptions { - exclude 'META-INF/NOTICE' - exclude 'META-INF/LICENSE' - } -} diff --git a/src/js/OT.coffee b/src/js/OT.coffee index ec350488..f4ce1b93 100644 --- a/src/js/OT.coffee +++ b/src/js/OT.coffee @@ -13,8 +13,8 @@ window.OT = checkSystemRequirements: -> return 1 - initPublisher: (one, two, three) -> - return new TBPublisher( one, two, three ) + initPublisher: (one, two) -> + return new TBPublisher( one, two ) initSession: (apiKey, sessionId ) -> if( not sessionId? ) then @showError( "OT.initSession takes 2 parameters, your API Key and Session ID" ) return new TBSession(apiKey, sessionId) diff --git a/src/js/OTPublisher.coffee b/src/js/OTPublisher.coffee index 3a1a92d4..36a028a6 100644 --- a/src/js/OTPublisher.coffee +++ b/src/js/OTPublisher.coffee @@ -15,8 +15,8 @@ # setStyle( style, value ) : publisher - not yet implemented # class TBPublisher - constructor: (one, two, three) -> - @sanitizeInputs( one,two, three ) + constructor: (one, two) -> + @sanitizeInputs(one, two) pdebug "creating publisher", {} position = getPosition(@domId) name="" @@ -113,33 +113,17 @@ class TBPublisher publishState = "false" pdebug "setting publishstate", {media: media, publishState: publishState} Cordova.exec(TBSuccess, TBError, OTPlugin, media, [publishState] ) - sanitizeInputs: (one, two, three) -> - if( three? ) - # all 3 required properties present: apiKey, domId, properties - # Check if dom exists - @apiKey = one - @domId = two - @properties = three - else if( two? ) - # only 2 properties are present, possible inputs: apiKey, domId || apiKey, properties || domId, properties - if( typeof(two) == "object" ) - # second input is property, so first input is either apiKey or domId - @properties = two - if document.getElementById(one) - @domId = one - else - @apiKey = one - else - # no property object is passed in - @apiKey = one - @domId = two + sanitizeInputs: (one, two) -> + if( two? ) + # all 2 optional properties present: domId, properties + @domId = one + @properties = two else if( one? ) - # only 1 property is present, apiKey || domId || properties + # only 1 property is present domId || properties if( typeof(one) == "object" ) @properties = one - else if document.getElementById(one) + else @domId = one - @apiKey = if @apiKey? then @apiKey else "" @properties = if( @properties and typeof( @properties == "object" )) then @properties else {} # if domId exists but properties width or height is not specified, set properties if( @domId and document.getElementById( @domId ) ) @@ -152,5 +136,4 @@ class TBPublisher @properties.height = position.height else @domId = TBGenerateDomHelper() - @domId = if( @domId and document.getElementById( @domId ) ) then @domId else TBGenerateDomHelper() - @apiKey = @apiKey.toString() + return @ \ No newline at end of file diff --git a/www/opentok.js b/www/opentok.js index 6afaa1c7..840e4182 100644 --- a/www/opentok.js +++ b/www/opentok.js @@ -2,8 +2,8 @@ window.OT = { checkSystemRequirements: function() { return 1; }, - initPublisher: function(one, two, three) { - return new TBPublisher(one, two, three); + initPublisher: function(one, two) { + return new TBPublisher(one, two); }, initSession: function(apiKey, sessionId) { if (sessionId == null) { @@ -275,14 +275,14 @@ var TBPublisher, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; TBPublisher = (function() { - function TBPublisher(one, two, three) { + function TBPublisher(one, two) { this.removePublisherElement = __bind(this.removePublisherElement, this); this.streamDestroyed = __bind(this.streamDestroyed, this); this.streamCreated = __bind(this.streamCreated, this); this.eventReceived = __bind(this.eventReceived, this); this.setSession = __bind(this.setSession, this); var audioBitrate, audioFallbackEnabled, audioSource, cameraName, frameRate, height, name, position, publishAudio, publishVideo, ratios, resolution, videoSource, width, zIndex, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; - this.sanitizeInputs(one, two, three); + this.sanitizeInputs(one, two); pdebug("creating publisher", {}); position = getPosition(this.domId); name = ""; @@ -430,32 +430,18 @@ TBPublisher = (function() { return Cordova.exec(TBSuccess, TBError, OTPlugin, media, [publishState]); }; - TBPublisher.prototype.sanitizeInputs = function(one, two, three) { + TBPublisher.prototype.sanitizeInputs = function(one, two) { var position; - if ((three != null)) { - this.apiKey = one; - this.domId = two; - this.properties = three; - } else if ((two != null)) { - if (typeof two === "object") { - this.properties = two; - if (document.getElementById(one)) { - this.domId = one; - } else { - this.apiKey = one; - } - } else { - this.apiKey = one; - this.domId = two; - } + if ((two != null)) { + this.domId = one; + this.properties = two; } else if ((one != null)) { if (typeof one === "object") { this.properties = one; - } else if (document.getElementById(one)) { + } else { this.domId = one; } } - this.apiKey = this.apiKey != null ? this.apiKey : ""; this.properties = this.properties && typeof (this.properties === "object") ? this.properties : {}; if (this.domId && document.getElementById(this.domId)) { if (!this.properties.width || !this.properties.height) { @@ -470,8 +456,7 @@ TBPublisher = (function() { } else { this.domId = TBGenerateDomHelper(); } - this.domId = this.domId && document.getElementById(this.domId) ? this.domId : TBGenerateDomHelper(); - return this.apiKey = this.apiKey.toString(); + return this; }; return TBPublisher;