enyo.js与其他javascript组件集成 [英] enyo.js to integrate with other javascript component

查看:84
本文介绍了enyo.js与其他javascript组件集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将enyo.js与opentok集成.无法确定如何包装将由opentok的javascript生成的视频组件.如果有人可以帮助我,如何将enyo与外部JavaScript(例如opentok)集成在一起,那就太好了.

I'm trying to integrate enyo.js with opentok. Can't figure how to wrap the video component which will be generated from opentok's javascript. If anyone can help me how to integrate enyo with external javascript such as opentok would be great.

我在下面的jsfiddle示例中创建了示例,该示例具有视频种类和opentok示例代码.我想使用enyo来生成视频,但是我是新手,需要enyo专家的帮助.

I have create below jsfiddle example which has video kind and opentok sample code. I would like generate the video using enyo kind but I'm newbie and need some help from experts in enyo.

http://goo.gl/nrsZQJ

推荐答案

我将根据我想完成的任务来回答这个问题.我们需要做的是围绕OpenTok视频流创建一个包装器.我并不十分熟悉它,但看起来我们可以使其将视频呈现到指定的div中.因此,我们要做的是创建一个包装对象(默认情况下)为div元素,并将该元素用作OpenTok的initPublisher方法的目标.呈现一种类型后,我们可以使用其hasNode()方法来获取有问题的节点.因此,我们最终得到如下内容:

I'm going to take a stab at answering this one based on what I think you want to accomplish. What we need to do is create a wrapper around the OpenTok video stream. I'm not terribly familiar with it but it looks like we can make it render its video into a div we specify. So, what we'll do is create a wrapper object that will (by default) be a div element and use that element as the target for OpenTok's initPublisher method. Once a kind is rendered we can use its hasNode() method to get the node in question. So, we end up with something like the following:

        var publisher = OT.initPublisher(this.hasNode());

为确保拥有节点,我们将在rendered方法中设置调用:

To be sure we have the node, we'll set up the calls within the rendered method:

    rendered: function() {
        this.inherited(arguments);
        if(this.session) {
            this.session.connect(token, this.bindSafely(this.connected));
        }
    },

我们可以使用session成员来访问所需的内容,从而将包装器方法添加到此类中.您还可以隐藏发布者或所需的任何其他部分.

We can add wrapper methods to the kind by using the session member to access what we need. You can also stash the publisher or any other parts you need.

根据您的简单示例,这是一个有用的小提琴.我已经将JavaScript移到了包装对象中.

Here's a working fiddle based on your simple example. I've moved the JavaScript into the wrapper object.

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

您将要在包装器上覆盖destroy,以便可以正确清理OpenTok会话.

You'll want to override destroy on the wrapper so you can clean up the OpenTok session properly.

这篇关于enyo.js与其他javascript组件集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆