首页 > 解决方案 > 无法集成 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}`);
      }
    });
  }

}

标签: ionic3ionic4opentok

解决方案


推荐阅读