Notification when player controls become visible / hidden?

I just want to know if it is possible to be notified when playback controls become visible or hidden?

For example, I want to introduce a video with a style:

self.moviePlayerController.controlStyle = MPMovieControlStyleEmbedded; 

When the video starts playing, the playback controls become visible and automatically disappear. If the user simply places a tab in the video, the controls will appear.

I need a notification so that I can customize my view (move some extra buttons to the MPMoviePlayerController . Is this possible? Because, unfortunately, I did not find anything in the documentation.

+6
source share
1 answer

I am afraid there are no registered notifications for these events.

You may be lucky and find something by sniffing all the published notifications, as in the following answers:

Track and track all notifications

How to get NSNotifications from native YouTube video playback in UIWebView


However, it is possible to simply link the controls to the MPMoviePlayerControler parameters. Thus, it is definitely undocumented, and it is at great risk of being refused when trying to sell your application on iTunes.

First you need to find the interface view in MPMoviePlayerController , which until today is represented by a class called MPInlineVideoOverlay using the built-in interface. Please note again that this has a great chance or breaks, as Apple may decide to use a different name any day.

 /** * This quirky hack tried to locate the interface view within the supposingly opaque MPMoviePlayerController * view hierachy. * @note This has a fat chance of breaking and/or getting rejected by Apple * * @return interface view reference or nil if none was found */ - (UIView *)interfaceViewWithPlayer:(MPMoviePlayerController *)player { for (UIView *views in [player.view subviews]) { for (UIView *subViews in [views subviews]) { for (UIView *controlView in [subViews subviews]) { if ([controlView isKindOfClass:NSClassFromString(@"MPInlineVideoOverlay")]) { return controlView; } } } } return nil; } 

If it returns the correct view, you simply add your own add-ons to the interface to it using the UIView addSubview: As soon as you do this, your controls will be part of the player’s interface, displayed and hidden with it (also keeping to all animations, etc. )

+5
source

Source: https://habr.com/ru/post/920883/


All Articles