如何使用Enyojs以编程方式添加新的div并附加到opentok的订户 [英] How to add programatically add new div using Enyojs and attach to the subscriber of opentok
问题描述
这是对的扩展堆栈流问题.我想以编程方式创建div并将opentok订户凸轮附加到它,并且所有订户凸轮都需要位于父div"#subscription"下.请让我知道我在代码中做错了什么.
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/
更新的Jsfiddle
Updated Jsfiddle
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.
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/
推荐答案
我相信您的代码存在的问题是hasNode()
将返回false
(或者它是null
?),因为未渲染该节点然而.将create:
更改为rendered:
,它可能会起作用.
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.
您没有说执行代码时-did-会发生什么.如果您只是获得空白的div,那么我的假设是正确的.
You didn't say what -did- happen when the code is executed. If you're just getting blank divs, then my assumption is correct.
这篇关于如何使用Enyojs以编程方式添加新的div并附加到opentok的订户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!