Skip to content

Commit 56df5f4

Browse files
author
ianyanzhang
committed
Optimize the picture-in-picture function experience
1 parent 8ee664d commit 56df5f4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,8 @@ - (void)appDidEnterPlayground:(NSNotification *)notify {
11921192
self.controlView.isDragging = NO;
11931193
[self.controlView setProgressTime:self.playCurrentTime totalTime:_vodPlayer.duration progressValue:value playableValue:playable];
11941194
[_vodPlayer seek:self.playCurrentTime];
1195+
} else if (self.state != StateStopped) {
1196+
self.repeatBtn.hidden = YES;
11951197
}
11961198
}
11971199

@@ -2233,11 +2235,11 @@ - (void)onPlayer:(TXVodPlayer *)player pictureInPictureStateDidChange:(TX_VOD_PL
22332235
[self.pipLoadingView stopAnimating];
22342236
self->_hasStartPipLoading = NO;
22352237
});
2236-
22372238
}
22382239

22392240
if (pipState == TX_VOD_PLAYER_PIP_STATE_RESTORE_UI) {
22402241
_restoreUI = YES;
2242+
[player exitPictureInPicture];
22412243
}
22422244

22432245
if (pipState == TX_VOD_PLAYER_PIP_STATE_DID_STOP) {
@@ -2459,14 +2461,25 @@ - (TXVodPlayer *)vodPlayer {
24592461

24602462

24612463
- (void)setPipLoadingWithText:(NSString *)text {
2462-
CGFloat width=[(NSString *)text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 21) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:DEFAULT_PIP_LOADING_FONT_SIZE]} context:nil].size.width;
2463-
2464-
_pipLoadingView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake((ScreenWidth - (width + DEFAULT_PIP_LOADING_WIDTH_MARGIN)) / 2, (ScreenHeight/2) - DEFAULT_PIP_LOADING_HEIGHT, width + DEFAULT_PIP_LOADING_WIDTH_MARGIN, DEFAULT_PIP_LOADING_HEIGHT * 2)];
2464+
CGFloat width=[(NSString *)text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 21)
2465+
options:NSStringDrawingUsesLineFragmentOrigin
2466+
attributes:@{NSFontAttributeName:
2467+
[UIFont systemFontOfSize:DEFAULT_PIP_LOADING_FONT_SIZE]}
2468+
context:nil].size.width;
2469+
CGFloat x = (ScreenWidth - (width + DEFAULT_PIP_LOADING_WIDTH_MARGIN)) / 2;
2470+
CGFloat y = (ScreenHeight/2) - DEFAULT_PIP_LOADING_HEIGHT;
2471+
CGFloat w = width + DEFAULT_PIP_LOADING_WIDTH_MARGIN;
2472+
CGFloat h = DEFAULT_PIP_LOADING_HEIGHT * 2;
2473+
_pipLoadingView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(x,y,w,h)];
24652474
_pipLoadingView.backgroundColor = [UIColor blackColor];
24662475
_pipLoadingView.layer.cornerRadius = 10;
24672476
_pipLoadingView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
24682477

2469-
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(DEFAULT_PIP_LOADING_LABEL_MARGIN, DEFAULT_PIP_LOADING_LABEL_MARGIN + DEFAULT_PIP_LOADING_HEIGHT, width, DEFAULT_PIP_LOADING_LABEL_HEIGHT)];
2478+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(
2479+
DEFAULT_PIP_LOADING_LABEL_MARGIN,
2480+
DEFAULT_PIP_LOADING_LABEL_MARGIN + DEFAULT_PIP_LOADING_HEIGHT,
2481+
width,
2482+
DEFAULT_PIP_LOADING_LABEL_HEIGHT)];
24702483
label.text = text;
24712484
label.font = [UIFont systemFontOfSize:DEFAULT_PIP_LOADING_FONT_SIZE];
24722485
label.textAlignment = NSTextAlignmentCenter;

0 commit comments

Comments
 (0)