Pawan
Pawan

Reputation: 1654

how to set a view layer to white when AVplayer is paused?

I am playing hls videos using AVPlayer inside a view. Now when stop the playback the video stops but the last frame, keeps showing in the view. Now i want to clear that frame and and make that view white, how do i do it? i have tried setting the view background to white but nothing happens.

Upvotes: 0

Views: 661

Answers (1)

Alex Chugunov
Alex Chugunov

Reputation: 748

Setting a background doesn't have any effect because AVPlayer renders its content on top of the background, completely overlaying it. You could just hide AVPlayer's view completely or set it's player property to nil when your AVPlayer finishes playing.

    [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
                                                  object:player
                                                   queue:[NSOperationQueue mainQueue]
                                              usingBlock:^(NSNotification *note) {
                                                  view.player = nil;
                                                  //or view.hidden = YES;
                                              }];

Upvotes: 1

Related Questions