addPeriodicTimeObserver生成转义的关闭错误

时间:2019-07-04 06:06:24

标签: swift macos closures avplayer swiftui

我正在关注这个tutorial,它解释了如何创建AVPlayer并将其与Swift UI一起使用。我位于搜寻栏变成视频播放器进度栏的地方。

因此,在那部分之后,我编写了本教程中显示的代码,但在下面的代码行中,

<!DOCTYPE HTML>
<html>

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Fancy Product Designer</title>

    <!-- Style sheets -->
    <link rel="stylesheet" type="text/css" href="css/main.css">

    <!-- The CSS for the plugin itself - required -->
    <link rel="stylesheet" type="text/css" href="css/FancyProductDesigner-all.min.css" />

    <!-- Include required jQuery files -->
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui.min.js" type="text/javascript"></script>

    <!-- HTML5 canvas library - required -->
    <script src="js/fabric.min.js" type="text/javascript"></script>
    <!-- The plugin itself - required -->
    <script src="js/FancyProductDesigner-all.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        jQuery(document).ready(function() {

            var $yourDesigner = $('#clothing-designer'),
                pluginOpts = {
                    productsJSON: 'json/products.json', //see JSON folder for products sorted in categories
                    designsJSON: 'json/designs.json', //see JSON folder for designs sorted in categories
                    stageWidth: 1200,
                    editorMode: false,
                    smartGuides: true,
                    fonts: [{
                        name: 'Helvetica'
                    }, {
                        name: 'Times New Roman'
                    }, {
                        name: 'Pacifico',
                        url: 'Enter_URL_To_Pacifico_TTF'
                    }, {
                        name: 'Arial'
                    }, {
                        name: 'Lobster',
                        url: 'google'
                    }],
                    customTextParameters: {
                        colors: false,
                        removable: true,
                        resizable: true,
                        draggable: true,
                        rotatable: true,
                        autoCenter: true,
                        boundingBox: "Base"
                    },
                    customImageParameters: {
                        draggable: true,
                        removable: true,
                        resizable: true,
                        rotatable: true,
                        colors: '#000',
                        autoCenter: true,
                        boundingBox: "Base"
                    },
                    actions: {
                        'top': ['download', 'print', 'snap', 'preview-lightbox'],
                        'right': ['magnify-glass', 'zoom', 'reset-product', 'qr-code', 'ruler'],
                        'bottom': ['undo', 'redo'],
                        'left': ['manage-layers', 'info', 'save', 'load']
                    }
                },

                yourDesigner = new FancyProductDesigner($yourDesigner, pluginOpts);

        });
    </script>
</head>

<body>
    <div id="main-container">
        <h3 id="clothing">Clothing Designer</h3>
        <div id="clothing-designer" class="fpd-container fpd-shadow-2 fpd-topbar fpd-tabs fpd-tabs-side fpd-top-actions-centered fpd-bottom-actions-centered fpd-views-inside-left"> </div>
        <br />

    </div>
</body>

</html>

player.addPeriodicTimeObserver(forInterval: CMTime(seconds: 0.5, preferredTimescale: 600), queue: nil) { time in guard let item = self.player.currentItem else{ return } self.seekPos = time.seconds / item.duration.seconds } 之前的括号用红色下划线标出,并且出现以下错误:

time in

是否可以解决此问题?我希望滑块成为视频进度条。 Escaping closure captures mutating 'self' parameter 位于我的addPeriodicTimeObserver内部的init中。

编辑:我正在使用的教程适用于iOS,但我正在针对macOS进行开发。我刚刚进行了更改,因此该教程中的代码适用于macOS。

1 个答案:

答案 0 :(得分:1)

尝试

dart.flutterSdkPath

希望能为您提供帮助。