我正在使用此仓库中的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: "", …}
`
任何帮助将不胜感激。
答案 0 :(得分:2)
此处是TokBox开发人员的传播者。
cycleVideo
方法仅可用于OpenTok JS SDK。要在使用Cordova OpenTok Plugin时切换相机,请使用以下方法:
publisher.setCameraPosition('front');
或publisher.setCameraPosition('back')
;
使用该插件,您还可以使用cameraName
属性作为一部分,使用前置或后置摄像机初始化Publisher对象initPublisher
方法的properties参数的形式,如下所示:
const publisherProperties = {
cameraName: 'front',
};
const publisher = OT.initPublisher(publisherProperties);