Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS AVPlayer时间观察程序崩溃_Ios_Avfoundation_Avplayer_Ios12_Swift4.2 - Fatal编程技术网

iOS AVPlayer时间观察程序崩溃

iOS AVPlayer时间观察程序崩溃,ios,avfoundation,avplayer,ios12,swift4.2,Ios,Avfoundation,Avplayer,Ios12,Swift4.2,自从升级到iOS 12/XCode 10和Swift 4.2以来,我一直在观察AVPlayer time observer中的崩溃。崩溃发生在播放相同的视频时,但不是每次都发生,这很奇怪。这是代码。我已经验证了间隔是0.004,而不是0。即使我手动将interval设置为1.0/30.0而不是计算,也会发生这种情况。我怀疑这次崩溃可能与Swift 4.2或iOS 12的某些变化有关 let width = Double(self.playerView.bounds.width)

自从升级到iOS 12/XCode 10和Swift 4.2以来,我一直在观察AVPlayer time observer中的崩溃。崩溃发生在播放相同的视频时,但不是每次都发生,这很奇怪。这是代码。我已经验证了间隔是0.004,而不是0。即使我手动将interval设置为1.0/30.0而不是计算,也会发生这种情况。我怀疑这次崩溃可能与Swift 4.2或iOS 12的某些变化有关

        let width = Double(self.playerView.bounds.width)
        var interval = 0.5*duration.seconds/width

        /* The time label needs to update at least once per second. */
        if interval > 1.0 {
           interval = 1.0
        }

        playerObserver = player.addPeriodicTimeObserver(forInterval: CMTime(seconds: interval, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), queue: DispatchQueue.main, using: { [weak self] time in
            self?.syncScrubber()
        })             

   *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVPeriodicTimebaseObserver initWithTimebase:interval:queue:block:] invalid parameter not satisfying: ((Boolean)(CMTimeCompare(interval, kCMTimeZero) > 0))'
*** First throw call stack:
(0x1e7a57ef8 0x1e6c25a40 0x1edab0be0 0x1eda65b18 0x10278eaec 0x10277d104 0x10277dc74 0x1e84c9d4c 0x1e84cc1e0 0x1e84c95d4 0x1eda91290 0x1043e3840 0x1043e4de4 0x1043f2a94 0x1e79e61bc 0x1e79e1084 0x1e79e05b8 0x1e9c54584