Skip to content

Life Cycle

changsanjiang edited this page Oct 20, 2019 · 2 revisions

In this page

Create And Destroy

    // Create player(strong reference)
    self.player = [[SJVideoPlayer alloc] init];

    // Destroy the player. if the player no strong reference, the player will automatically destroy
    self.player = nil;

Pause Or Resume Playback

@implementation DemoViewController
// Pause playback when view did disappear
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [self.player pause];
    self.player.vc_isDisappeared = YES;
}

// Resume playback when view did appear
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.player play];
    self.player.vc_isDisappeared = NO;
}
@end
Clone this wiki locally