SAP Fiori UI5从视频捕获快照

问题描述 投票:0回答:1

我正在做一个小的操作。我想从视频中捕获多个图像。我这样做时正在使用fixedDialog。但是拍照后,再次打开fixedDialog时看不到视频。我在下面分享我的代码。

第一次打开视频,

enter image description here

捕获后,

enter image description here

<Button text="Resim Ekle" width="100px" id="idCapture" press="takePhoto"/>
            <Vbox id="wow">
                <Vbox id="canvasContainer">
                </Vbox>
            </Vbox>

    takePhoto: function(oEvent) {
        // Create a popup object as a global variable
        var that = this;
        that.fixedDialog = new Dialog({
            title: "Fotoğraf çekmek için tıklayınız",
            beginButton: new sap.m.Button({
                text: "Resim Çek",
                press: function() {
                    that.imageVal = document.getElementById("player");
                    that.fixedDialog.close();
                }
            }),
            content: [
                new sap.ui.core.HTML({
                    content: "<video id='player' autoplay/>"
                }),
                new sap.m.Input({
                    placeholder: 'Lütfen resim adını giriniz',
                    required: false
                })
            ],
            endButton: new sap.m.Button({
                text: "İptal",
                press: function() {
                    that.fixedDialog.close();
                }
            })
        });
        that.getView().addDependent(this.fixedDialog);
        this.fixedDialog.open();
         that.fixedDialog.attachBeforeClose(this.setImage, this);
        var handleSuccess = function(stream) {
            player.srcObject = stream;
        };
        navigator.mediaDevices.getUserMedia({
            video: true
        }).then(handleSuccess);
    },
    setImage: function() {
        var oVBox = this.getView().byId("wow");
        var canvasContainer = this.getView().byId("canvasContainer");
        var items = oVBox.getItems();
        var snapId = 'canvas-' + items.length;
        var textId = snapId + '-text';
        var imageVal = this.imageVal;
        var snapImg = null;
        var snapCanvas = new sap.ui.core.HTML({
            content: "<canvas display:none id='" + snapId + "'  width='400' height='200' ></canvas>"
        });
        oVBox.addItem(snapCanvas);
        snapCanvas.addEventDelegate({
            onAfterRendering: function() {
                    var canvasElem = document.getElementById(snapId);
                    var snapCanvasContext = canvasElem.getContext('2d');
                    snapCanvasContext.drawImage(imageVal, 0, 0, canvasElem.width, canvasElem.height);
            }
        });

    }
sapui5 sap abap sap-fiori
1个回答
0
投票

我建议您在执行this.fixedDialog之前先检查new Dialog()是否存在:我怀疑您在再次打开对话框时要添加多个<video id='player' autoplay/> ...

© www.soinside.com 2019 - 2024. All rights reserved.