AVPlayer的专业崩溃

时间:2015-12-03 23:39:55

标签: ios xcode swift

我正在尝试使用AVPlayer播放视频并在主视图中添加子图层播放器。它适用于我的手机,但它在iPhone 6 iOS 8.3上崩溃

下面是堆栈跟踪。关于如何解决的任何想法?

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)
    }

0 个答案:

没有答案