I am working on tvOS app. I have multiple videos in grid formate. I used AVPlayerViewController to play videos in the app. AVPlayerViewController shows default activity indicator but my requirement is add to custom activity indicator in AVPlayerViewController. How to add custom indicator using swift. Please suggest it.
Asked
Active
Viewed 629 times
1 Answers
0
First of all, you need to remove a default activity indicator. You can find an activity indicator in AVPlayerViewController subViews and change style or hide it. Use the following code (it is an Objective-C code but you can rewrite it in Swift):
- (void)findActivityIndicatorInView:(UIView *)view toPerformBlock:(void(^)(UIActivityIndicatorView*))block {
NSArray *subviews = [view subviews];
for (UIView *subview in subviews) {
if ([subview isKindOfClass:[UIActivityIndicatorView class]]) {
block((UIActivityIndicatorView*)subview);
}
[self findActivityIndicatorInView:subview toPerformBlock:block];
}
}
And add this call:
[self findActivityIndicatorInView:self.playerController.view toPerformBlock:^(UIActivityIndicatorView* v) {
//Your actions
}];
After you can add your custom activity indicator in front of the AVPlayerViewController
view.

Roman Podymov
- 4,168
- 4
- 30
- 57