ios - How to add OverLay View in UIWebView Video Player? -


i want add custom controls on uiwebview's video player. able add control on below code : first adding below notification,

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(addoverlayview:) name:uiwindowdidbecomevisiblenotification object:nil];  

then on receiving of it,

-(void)addoverlayview:(nsnotification*)anotification{     uiwindow *window = (uiwindow *)anotification.object;      if (window != self.view.window) {         [window addsubview:anycustomview];     } } 

but view statically on top of uiwebview's video view. wants achieve when controls of video player hide want hide custom view.

in other words wants achieve custom overlayview on uiwebview's video player view.

please me regarding this.

it seems not possible "out of box". docs state movie player emits notifications in these situations :

when movie player begins playing, paused, or begins seeking forward or backward when airplay playback starts or ends when scaling mode of movie changes when movie enters or exits fullscreen mode when load state network-based movies changes when meta-information movie becomes available 

so there no way of getting know when controls did hide/show.

if want show view once, after user opens view, can achieve pretty easily, example animation :

-(void)addoverlayview:(nsnotification*)anotification{     uiwindow *window = (uiwindow *)anotification.object;      if (window != self.view.window) {         [window addsubview:anycustomview];          [uiview animatewithduration:2 //choose fitting value here                               delay:3 //this has chosen experimentally if want match timing of when controls hide                             options:uiviewanimationoptioncurveeaseout                          animations:^{                              anycustomview.alpha = 0.0f; //fadeout animation, can leave block empty have no animation                        } completion:^(bool finished) {                              [anycustomview removefromsuperview];                        }];     } } 

note not hide view when user discards controls.

if want show/hide view every time controls shown/hidden gets more trickier. 1 approach disable standard controls , recreate them - bear in mind not easy.


Comments