简体   繁体   English

UI5应用程序中导入的库在调用时消失

[英]Imported library in UI5 app disappear when calling it

I have downloaded this library into my project and put it into "lib" folder in my project. 我已将此库下载到我的项目中,并将其放入我项目中的“ lib”文件夹中。 项目文件夹树

Then I add it into the cotroller of my view, when I want to call it when clicking the button, as described in the documentation 然后,当我想在单击按钮时调用它时,将其添加到视图的cotroller中,如文档所述

sap.ui.define([
   "sap/ui/core/mvc/Controller",
   "Test_ScreenRecordingTest_ScreenRecording/lib/RecordRTC"
], function(Controller, RecordRTC) {
"use strict";

return Controller.extend("Test_ScreenRecordingTest_ScreenRecording.controller.View1", {
    onStartRecording: function(){
        debugger;

        var mediaConstraints = { video: true, audio: true };
        navigator.mediaDevices.getUserMedia(mediaConstraints).then(this.successCallback.bind(this)).catch(this.errorCallback);
    },

    successCallback: function(stream) {
        // RecordRTC usage goes here
        var options = {
          mimeType: 'video/webm', // or video/webm\;codecs=h264 or video/webm\;codecs=vp9
          audioBitsPerSecond: 128000,
          videoBitsPerSecond: 128000,
          bitsPerSecond: 128000 // if this line is provided, skip above two
        };
        //jQuery.sap.require("Test_ScreenRecordingTest_ScreenRecording.lib.RecordRTC");
        this.recordRTC = RecordRTC(stream, options);
        this.recordRTC.startRecording();
    },

    errorCallback: function(error) {
        console.log(error)
        debugger;
    },

    onStopRecording: function(){
        this.recordRTC.stopRecording(function (audioVideoWebMURL) {
            video.src = audioVideoWebMURL;

            var recordedBlob = this.recordRTC.getBlob();
            debugger;
            this.recordRTC.getDataURL(function(dataURL) {
                debugger;
            });
        });
    }
});

If I don't use the RecordRTC variable, I can see it in the debugger. 如果我不使用RecordRTC变量,则可以在调试器中看到它。 If I use it, it appears as "undefined". 如果使用它,它将显示为“未定义”。 So can never call it. 因此永远不能调用它。

Could you please help??Ç 你能帮忙吗?

EDIT 09-feb-2018: Solved declaring a new variable in the Controller extension 编辑2018年2月9日:解决了在Controller扩展中声明新变量的问题

return Controller.extend("Test_ScreenRecordingTest_ScreenRecording.controller.View1", {

    //this line solved the issue
    RecordRTC: RecordRTC,

    onStartRecording: function(){
        debugger;

        var mediaConstraints = { video: true, audio: true };
        navigator.mediaDevices.getUserMedia(mediaConstraints).then(this.successCallback.bind(this)).catch(this.errorCallback);
    },

Thank you in advance 先感谢您

The dependency string in your code looks strange: "Test_ScreenRecording Test_ScreenRecording /lib/RecordRTC". 您的代码中的依赖项字符串看起来很奇怪:“ Test_ScreenRecording Test_ScreenRecording / lib / RecordRTC”。

Can it be a typo? 可以打错字吗?

Anyway, the dependency path should be like this: " <app ID from manifest.json> /lib/RecordRTC". 无论如何,依赖路径应该是这样的:“ <manifest.json中的应用ID> / lib / RecordRTC”。

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

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