Skip to content

Commit

Permalink
应用切换至后台时,停止播放视频
Browse files Browse the repository at this point in the history
  • Loading branch information
longitachi committed Feb 20, 2019
1 parent 60b58c6 commit dd24a09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PhotoBrowser/ZLBigImageCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ - (void)placeSubviews

[self addSubview:self.imageView];
[self addSubview:self.indicator];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

- (void)controllerScrollViewDidScroll
Expand All @@ -823,6 +824,13 @@ - (void)controllerScrollViewDidScroll
}
}

- (void)appDidEnterBackground:(NSNotification *)notify
{
if (_playLayer.player && _playLayer.player.rate != 0) {
[self playBtnClick];
}
}

- (void)loadNormalImage:(PHAsset *)asset
{
[super loadNormalImage:asset];
Expand Down Expand Up @@ -990,6 +998,14 @@ - (void)placeSubviews
[self.layer addSublayer:self.playLayer];
[self addSubview:self.playBtn];
[self addSubview:self.indicator];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

- (void)appDidEnterBackground:(NSNotification *)notify
{
if (_playLayer.player && _playLayer.player.rate != 0) {
[self playBtnClick];
}
}

- (void)loadNetVideo:(NSURL *)url
Expand Down

0 comments on commit dd24a09

Please sign in to comment.