ios - 样式默认 "No video source"/"No video permissions"黑色矩形

标签 ios css safari quaggajs

当提示用户在 Safari 上获得许可时,视频元素显示为带有删除线播放按钮的黑色矩形。如何更改此元素的样式?它有特定的 ID/类别/标签吗?

我正在使用 Quagga JS 作为条码扫描仪。 AFAIK Quagga 创建一个 video 元素,然后请求相机许可。最佳结果是使用 display:none; 隐藏元素,但我想不出任何方法来实现这一点。我需要该元素在扫描仪获得许可后显示相机画面,但在此之前它应该将屏幕涂黑或隐藏。

safari video css issue

最佳答案

我通过 JavaScript 隐藏它并在 Quagga 反馈完成后显示它来修复它。请注意,纯 CSS 解决方案会更漂亮。

// Hide the preview before it's fully initialised.
    $('#videoBoundingBox').hide();
    Quagga.init({
        inputStream: {
            name: "Live",
            type: "LiveStream",
            target: document.querySelector('#videoBoundingBox')
        },
        decoder: {
            readers: [
                "code_128_reader",
                "ean_reader"
            ]
        }
    }, function (err) {
        if (err) {
            console.log(err);
            setResult(err);
            err = err.toString();
            if (err.search("NotFoundError")) {
                // No camera found. The user is probably in an office environment.
                // Redirect to previous orders or show a background image of sorts.
            } else if (err.search("NotAllowedError")) {
                // The user has blocked the permission request.
                // We should ask them again just to be sure or redirect them.
            } else {
                // Some other error.
            }


            return;
        }
        // Hide the preview before it's fully initialised.
        $('#videoBoundingBox').show();
        setResult("Initialization finished. Ready to start");
        console.log("Initialization finished. Ready to start");
        Quagga.start();
        initializeQuaggaFeedback();
    });

关于ios - 样式默认 "No video source"/"No video permissions"黑色矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53203511/

相关文章:

ios - 为什么在删除核心数据中的对象之前需要删除关系?

ios - Swift 3,如何首先解析并在下一个 TableViewController 上显示它

html - 如何使鼠标悬停在图像 map 上时出现文本框?

同一行上的 jquery 显示/隐藏按钮显示不漂亮 - 在动画期间导致半高?

ios - 防止 UITextView.typingattributes 在 Swift 中的换行符 (\n) 上应用 backgroundColor

javascript - 将 rem 转换为 px 而不回流

javascript - Safari 和 Chrome 中的 iframe 问题

javascript - Angular 表单上传在 Safari 中不起作用,在 Chrome 中起作用

ios - 我如何了解 UIApplication 是否要在 Safari 应用程序中打开链接?

ios - DidDisappear 从另一个线程调用并有延迟