如何使用Enyojs以编程方式添加新的div并附加到opentok的订阅者



这是对堆叠流问题的扩展。我想以编程方式创建div,并将opentok订阅者摄像头附加到它上,所有订阅者摄像头都需要在父div"#subscription"下。请让我知道我在代码中做错了什么。

Jsfidle

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

更新Jsfidle

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

订阅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());
    }
});

更新

我想将流附加到subscribeButton,下面的代码将第一个订阅者流添加到"#subscribeButton"。如果存在第二个订阅流,则它将用第二个流覆盖先前的订阅凸轮视频。我想让所有的订阅者都能在屏幕上看到。所以我尝试使用create函数创建新的div。

  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/

我认为您的代码的问题是hasNode()将返回false(还是null?),因为节点尚未渲染。将create:更改为rendered:,它可能会起作用。

你小提琴里的代币已经过期了,所以我无法进一步测试,但无法。创建新组件的代码乍一看是正确的。

您没有说明代码执行时发生了什么。如果你只是得到了空白的div,那么我的假设是正确的。

最新更新