ionic3 - 无法集成 Opentok 音频视频控件
问题描述
我能够集成 Opentok 提供的 api,但是当建立连接时,我看不到任何视频或音频控件。暂停音频或视频。
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
Opentok 宣布
declare var OT: any;
export class HomePage {
session: any;
publisher: any;
apiKey: any;
sessionId: string;
token: string;
constructor(public navCtrl: NavController) {
this.apiKey = '5489';
this.sessionId = 'abc';
this.token = 'xyz';
}
startCall() {
this.session = OT.initSession(this.apiKey, this.sessionId);
this.publisher = OT.initPublisher('publisher');
// when connection is established
this.session.on({
streamCreated: (event: any) => {
this.session.subscribe(event.stream, 'subscriber');
OT.updateViews();
},
streamDestroyed: (event: any) => {
console.log(`Stream ${event.stream.name} ended because ${event.reason}`);
OT.updateViews();
},
sessionConnected: (event: any) => {
this.session.publish(this.publisher);
}
});
// 连接时
this.session.connect(this.token, (error: any) => {
if (error) {
console.log(`There was an error connecting to the session ${error}`);
}
});
}
}
解决方案
推荐阅读
- node.js - Express.js - 运行服务器 3 小时后未发送 Cookie
- android - 我想从我的 Android 应用程序的 firebase 数据库中检索数据到下拉菜单中
- f# - 构建大型功能地图?(F#)
- camunda - 异步启动进程
- c# - ADAL AcquireTokenByRefreshTokenAsync 未更新 TokenCache
- javascript - 如何使用 url 参数中的上一页输入的输入值预填充 html 代码?
- java - iText - 在文档底部添加一个固定段落
- amazon-ecs - 尽管 ECS 代理已连接,但 AWS ECS(容器服务)不会启动容器
- excel - 如何使用 Excel VBA 向范围内的唯一用户发送电子邮件?
- json - 如何从网站获取 json 文件并将其放入 MS 访问数据库中