songz / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
Other
162 stars 270 forks source link

streamCreated event not firing #189

Open u84six opened 9 years ago

u84six commented 9 years ago

Does anyone know why this isn't happening? I'm just trying to do a quick test and subscribe to what I'm publishing (Like OpenToks sample app). How can I do that with the plugin?

app = {
    initialize: function() {
        opentok.addEventListener( 'exception', function(e){
            console.log( e.message );
        });
    },

    publish: function() {
        var publisher = opentok.initPublisher(apiKey, "opentok-container", {width: 240, height: 180});

        var session = opentok.initSession(apiKey, sessionId);

        session.on({
            'sessionConnected': function() {
                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, {width: 120, height: 90, subscribeToAudio: true, subscribeToVideo: true});
            }
        });

        session.connect(token);
    }
};
prabinyovan commented 9 years ago

I think streamCreated event will fire only when if some one joins the session and publish their video.