Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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_Xcode_Swift - Fatal编程技术网

Ios 使用AVPlayer进行专门的崩溃

Ios 使用AVPlayer进行专门的崩溃,ios,xcode,swift,Ios,Xcode,Swift,我正在尝试使用AVPlayer播放视频,并在主视图中添加一个子层播放器。它在我的手机上工作,但在iPhone6iOS8.3上却崩溃了 下面是stacktrace。有没有关于如何修复的想法 Thread : Crashed: com.apple.main-thread 0 Tether 0x100157bbc specialized TetherDetailViewController.(playVideo in _76F367FEC7F29890

我正在尝试使用AVPlayer播放视频,并在主视图中添加一个子层播放器。它在我的手机上工作,但在iPhone6iOS8.3上却崩溃了

下面是stacktrace。有没有关于如何修复的想法

Thread : Crashed: com.apple.main-thread
0  Tether                         0x100157bbc specialized TetherDetailViewController.(playVideo in _76F367FEC7F2989028C7D8B91C1E249D)(NSURL) -> () (TetherDetailViewController.swift:127)
1  Tether                         0x100158544 partial apply for TetherDetailViewController.(viewWillAppear(TetherDetailViewController) -> (Bool) -> ()).(closure #1).(closure #1) (TetherDetailViewController.swift:38)
2  libdispatch.dylib              0x1987f9994 _dispatch_call_block_and_release + 24
3  libdispatch.dylib              0x1987f9954 _dispatch_client_callout + 16
4  libdispatch.dylib              0x1987fe20c _dispatch_main_queue_callback_4CF + 1608
5  CoreFoundation                 0x18693b7f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
6  CoreFoundation                 0x1869398a0 __CFRunLoopRun + 1492
7  CoreFoundation                 0x1868652d4 CFRunLoopRunSpecific + 396
8  GraphicsServices               0x19007b6fc GSEventRunModal + 168
9  UIKit                          0x18b42afac UIApplicationMain + 1488
10 Tether                         0x1001209d0 main (AppDelegate.swift:15)
11 libdyld.dylib                  0x198826a08 start + 4
这就是它所说的崩溃的功能:

private func playVideo(videoURL: NSURL) {
        if player == nil {
            let player = AVPlayer(URL: videoURL)
            player.actionAtItemEnd = .None
            let layer = AVPlayerLayer()
            layer.player = player
            layer.frame = videoView.frame
            //videoTitleLabel.text = currentTether.title
            //layer.frame = CGRectMake(0, 0, cell.containerView.frame.width, cell.containerView.frame.height)
            layer.backgroundColor = UIColor.tetherOrange().CGColor
            layer.videoGravity = AVLayerVideoGravityResizeAspectFill

            view.layer.addSublayer(layer)
            self.player = player
        }

        player.play()
        videoFinished = false
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "itemDidFinishPlaying:", name: AVPlayerItemDidPlayToEndTimeNotification, object:self.player.currentItem)
    }

预览层已连接到会话,该会话具有具有物理设备的输入设备。你在模拟器上运行这个吗?听起来像是在代码中设置AVCaptureSession的其他地方试图访问一个不在模拟器上的摄像头设备。@MatthewLawrenceBailey这是在实际设备上。它也在播放来自url的视频,不录制任何内容。什么时候崩溃?视图第一次出现时?或者是在藏起来之后又回来了?关于坠机发生的时间/方式,您还可以提供其他详细信息吗?另外,哪一行是第127行?您的预览层连接到会话,该会话具有具有物理设备的输入设备。你在模拟器上运行这个吗?听起来像是在代码中设置AVCaptureSession的其他地方试图访问一个不在模拟器上的摄像头设备。@MatthewLawrenceBailey这是在实际设备上。它也在播放来自url的视频,不录制任何内容。什么时候崩溃?视图第一次出现时?或者是在藏起来之后又回来了?关于坠机发生的时间/方式,您还可以提供其他详细信息吗?还有,第127行是哪一行?