OpenTok Ionic 3 - publisher.cycleVideo 函数未找到

OpenTok Ionic 3 - publisher.cycleVideo function not found

我正在使用这个 repo 中的 ionic opentok 插件, https://github.com/opentok/cordova-plugin-opentok 当然,我已经关注了 https://github.com/opentok/opentok-cordova-samples 个项目并构建了一个应用程序。但是,我正在努力在正在进行的视频会话中切换相机。 我的代码很简单,屏幕上的一个按钮,

<div class="controls-btn-inner-icon" (click)="toggleCamera()">
    <ion-icon ios="md-camera" md="md-camera"></ion-icon>
</div>

和方法,

toggleCamera() {
    this.publisher.cycleVideo();
}

它在调试控制台上给我错误,

TypeError: this.publisher.cycleVideo is not a function
        [[StableObjectId]]:3
        message:"this.publisher.cycleVideo is not a function"
        ngDebugContext:DebugContext_ {view: Object, nodeIndex: 106, nodeDef: Object, …}
        ngErrorLogger:function () { … }
        stack:"TypeError: this.publisher.cycleVideo is not a function\n    at 
    VideoSessionPage.webpackJsonp.92.VideoSessionPage.toggleCamera (http://localhost:8080/build/main.js:936:24)\n    at Object.eval [as handleEvent] (ng:///AppModule/VideoSessionPage.ngfactory.js:247:31)\n    at handleEvent (http://localhost:8080/build/vendor.js:14275:155)\n    at callWithDebugContext (http://localhost:8080/build/vendor.js:15784:42)\n    at Object.debugHandleEvent [as handleEvent] (http://localhost:8080/build/vendor.js:15371:12)\n    at dispatchEvent (http://localhost:8080/build/vendor.js:10690:25)\n    at http://localhost:8080/build/vendor.js:11315:38\n    at HTMLDivElement.<anonymous> (http://localhost:8080/build/vendor.js:40626:53)\n    at t.invokeTask (http://localhost:8080/build/polyfills.js:3:15660)\n    at Object.onInvokeTask (http://localhost:8080/build/vendor.js:5437:33)"
    __proto__:Error {constructor: , name: "TypeError", message: "", …}

`

任何帮助将不胜感激。

此处为 TokBox 开发人员布道师。

cycleVideo方法只适用于OpenTok JS SDK. To toggle the camera when using the Cordova OpenTok Plugin,请使用以下方法: publisher.setCameraPosition('front');publisher.setCameraPosition('back');

使用该插件,您还可以像这样初始化 Publisher object with either the front or the back camera using the cameraName property as part of the properties argument for the initPublisher 方法:

const publisherProperties = {
  cameraName: 'front',
};
const publisher = OT.initPublisher(publisherProperties);