繁体   English   中英

带有joomla的OpenTok

[英]OpenTok with joomla

我正在使用OPENTOK api创建基本的视频聊天。 我有在核心php中正常工作的代码,但是当我与joomla 2.5一起使用时的代码相同。 页面显示为空白。 代码如下。

 <script src='//static.opentok.com/webrtc/v2.2/js/opentok.min.js'></script>
  <script type="text/javascript">
    var apiKey = "<api key here>";
    var sessionId = "<session id>";
    var token = "<Token here>";


    TB.setLogLevel(TB.DEBUG);
    var session = OT.initSession(apiKey, sessionId); 
    session.on({ 
        streamCreated: function(event) { 
          session.subscribe(event.stream, "videos", {insertMode: 'append'}); 
        } 
    }); 
    session.connect(token, function(error) {
      if (error) {
        console.log( error );
      } else {
        session.publish('myPublisherDiv', {width: 264, height: 198}); 
      }
    });
  </script>
  <div id="videos">
    <div id="myPublisherDiv" style="margin-bottom:10px"></div>
  </div>

提前致谢。

上面的代码在哪里插入?

如果要创建扩展,则为了在joomla中添加javascript,您需要例如执行以下操作:

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
    window.event("domready", function() {
        alert("An inline JavaScript Declaration");
    });
');
?>

如果必须包含js文件:

<?php
$document = JFactory::getDocument();
$document->addScript('/media/system/js/sample.js');
?>

有关更多信息,您可以访问(这是示例的来源): http : //docs.joomla.org/Adding_JavaScript

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM