mhergon/AVPlayerViewController-Subtitles

crash

Closed this issue · 1 comments

2016-07-03 16:41:33.402 Dog Trainer[6570:2093417] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
Unable to interpret '|' character, because the related view doesn't have a superview
H:|-(20)-[l]-(20)-|
^'
*** First throw call stack:
(0x180b3edb0 0x1801a3f80 0x1815f898c 0x18147a680 0x181479490 0x181479070 0x100138394 0x100137484 0x100138920 0x1000bbd48 0x1000bc0ac 0x185c9cc40 0x185cb50d0 0x185e4fe5c 0x185d5be40 0x185d5bb1c 0x185d5ba84 0x185c981e4 0x18362a994 0x1836255d0 0x183625490 0x183624ac0 0x183624820 0x185c8e5f8 0x180af4728 0x180af24cc 0x180af28fc 0x180a1cc50 0x182304088 0x185d06088 0x1000be894 0x1805ba8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

schermata 2016-07-03 alle 16 43 33

    navigationItem.title = command?.name

    if let c = command, videoURL = NSBundle.mainBundle().URLForResource(c.movieFilename, withExtension: "mp4") {
        let player = AVPlayer(URL: videoURL)
        playerController.player = player

        if let subs = NSBundle.mainBundle().URLForResource(c.subtitlesFilename, withExtension: "srt") {
            playerController.addSubtitles().open(file: subs)
        }

        if let pv = playerView {
            pv.addSubview(playerController.view)
            playerController.view.frame = pv.frame
        }
    }

I was quite dumb, I've added subtitles before adding player controller's view to my main view