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

前端 未结 5 1390
滥情空心
滥情空心 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:22

    When using KVO you must balance calls to addObserver:forKeyPath:options:context: with calls to removeObserver:forKeyPath: (see the KVO programming guide).

    Try removing the view controller as an observer when the stop button is tapped e.g.

    - (IBAction)btnStop_Click:(id)sender {
        [[player currentItem] removeObserver:self forKeyPath:@"timedMetadata"];
    }
    

提交回复
热议问题