I am not able to see OPENTOK subscriber video in my cordova app

I installed the following plugin in my cordova application:

I am able to connect my devices to the same session but I can't see the subscribers stream on each device screen.

I can only see my own stream.

Here is the code of my index.js:

var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},

bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},

onDeviceReady: function() {
app.receivedEvent('deviceready');
},

receivedEvent: function(id) {

var apiKey = "44684902";
var sessionId = "2_MX40NDY4NDkwMn5-VHVlIE1hciAxMSAwNzo0NjoxNyBQRFQgMjAxNH4wLjIyMDExNzk5fg";
var token =   "T1==cGFydG5lcl9pZD00NDY4NDkwMiZzZGtfdmVyc2lvbj10YnJ1YnktdGJyYi12MC45MS4yMDExLTAyLTE3JnNpZz04OGU4ODg4NTEyYTFhZTcyNWNkOGJiOWQ0ODhlMjA2ZWQ5NjI1YmJmOnJvbGU9cHVibGlzaGVyJnNlc3Npb25faWQ9Ml9NWDQwTkRZNE5Ea3dNbjUtVkhWbElFMWhjaUF4TVNBd056bzBOam94TnlCUVJGUWdNakF4Tkg0d0xqSXlNREV4TnprNWZnJmNyZWF0ZV90aW1lPTEzOTQ1NDkyMDAmbm9uY2U9MC4zNTU5Mzc3NzU5MDg3MjIyJmV4cGlyZV90aW1lPTEzOTQ1NzA3NjImY29ubmVjdGlvbl9kYXRhPQ==";

var publisher = TB.initPublisher(apiKey,'myPublisherDiv' );
var session = TB.initSession( sessionId );
session.on({
    'sessionConnected': function( event ){
      session.publish( publisher );
    },
    'streamCreated': function( event ){
        var div = document.createElement('div');
        div.setAttribute('id', 'stream' + event.stream.streamId);
        document.body.appendChild(div);
        session.subscribe( event.stream, div.id);
    }
  });
  session.connect( apiKey, token );

  }
  };

Answers


Your code seems to have multiple problems. First, sessionIds should not have any white spaces in them. Second, you session.on method does not have a closing parenthesis ).

Cordova is not good at detecting javascript errors, I highly recommend using weinre as a debugging tool.

I have included some sample code in the examples folder in the repository at https://github.com/songz/cordova-plugin-opentok.git

You can try replacing your www folder with the www folder in the examples directory. The repository's readme file has explanations about the sample code and how to get it working.

Hope that helps!


Need Your Help

Assignment with line continuation - Python

python styling pep

I hope I'm not breaking any SO rules with this one: what is the preferred style for assigning values to variables when the variables are nested several levels deep, have fairly long names, and are ...

shell script to process a file and do math on it

regex shell sed

I have a file with data in this format.