0

This is an extention to stackflow qustion. I want to create div programmatically and attach the opentok subscriber cam to it and all the subscriber cam need to come under parent div "#subscription". Please let me know what I'm doing wrong in my code.

Jsfiddle

http://jsfiddle.net/6z9n65ty/55/

Updated Jsfiddle

http://jsfiddle.net/6z9n65ty/59/

Code for subscription div

    enyo.kind({
    name : "blanc.SubscriberWrapper",
    showing: true,
    stream: null,
    session: null,
    create: function(){
        this.inherited(arguments);
        if(this.stream != null && this.session != null){
            this.subscribe();
        }
    },
    subscribe: function(){
        this.session.subscribe(this.stream, this.hasNode());
    }
});

Update

I want to attach the stream to subscribeButton, the below code will add the first subscriber stream to "#subscribeButton". If second subscribe stream exist, then it will overwrite previous subscribe cam video with second stream. I want to have all the subscribers to be viewed in the screen. So I was trying to create new div using create function.

  streamCreated: function (event) {
      this.session.subscribe(event.stream, subscribeButton);
     // Add subscriber stream to a new div 
     //   this.createComponent({kind: "blanc.SubscriberWrapper", name : event.stream.id, stream: event.stream, session: this.session});
//  this.render();
  },

JSFIDDLE

http://jsfiddle.net/6z9n65ty/62/

Community
  • 1
  • 1
user1595858
  • 3,700
  • 15
  • 66
  • 109

1 Answers1

0

I believe the problem with your code is that hasNode() will return false (or is it null?) because the node isn't rendered yet. Change create: to rendered: and it may work.

The token in your fiddle had expired so I wasn't able to test it further but couldn't. Your code that creates the new component looks correct at first blush.

You didn't say what -did- happen when the code is executed. If you're just getting blank divs, then my assumption is correct.

Pre101
  • 2,370
  • 16
  • 23
  • I have updated the code and also generated token dynamically. Can you check now? – user1595858 Feb 12 '15 at 20:29
  • You'll have to give me reproduction steps and a better description of what does happen. – Pre101 Feb 12 '15 at 21:04
  • I have uncommented this.session.subscribe(event.steam, subscribeButton); now the first subscriber video will be attached to "subscribeButton". It works only if there is only one subscriber. I want it to work if the subscribers dynamically adds up. – user1595858 Feb 12 '15 at 21:49
  • What does happen when another subscriber appears? Have you added debugging to be sure things are happening in the places you expect? Does the element get added to the parent? Does the subscribe get called? – Pre101 Feb 13 '15 at 00:12
  • The element doesn't get added to the parent. Yes subscriber gets called when you have the jsfiddle open from two different browsers. Still debugging the issue. – user1595858 Feb 13 '15 at 00:20
  • The element does get created and added the first time. The problem must be in your OpenTOK code. – Pre101 Feb 13 '15 at 05:16