AVPlayer was deallocated while key value observers were still registered with it

前端 未结 5 1449
滥情空心
滥情空心 2021-01-31 08:45

I am creating a simple media player app. My App is crashed when first link is played and I clicked second link in uitableview.

- (void)viewDidLoad {
        [s         


        
5条回答
  •  灰色年华
    2021-01-31 09:16

    I did meet the similar issue when using AVPlayer, the crash log info says:

    An instance 0x174034600 of class AVKeyPathFlattener was deallocated while key value observers were still registered with it. Current observation info: ( Context: 0x0, Property: 0x17405d6d0> )

    As what Apple recommended, what I originally did is adding observer after initialize my AVPlayerItem object, and remove observer in the observer's dealloc method. Because my observer class kept a strong reference on my AVPlayerItem object, so it should not be deallocated before my observer object was deallocated. I really don't know why this happens.

    So I tried solved this problem by using BlocksKit, it works fine for me right now.

提交回复
热议问题