3

I have a UIWebView on screen, which automatically redraws when the device is rotated. I don't want it to redraw if the user has invoked a video from the web before rotating because redrawing cancels the video playback (although audio continues).

None of the following helped:

  • UIWebView is not hidden by MPMoviePlayer instance
  • Media playback does not invoke viewWillAppear, viewDidAppear, viewWillDisappear, or viewDidDisappear.
  • self.view.window doesn't change, doesn't get any new subviews
  • UIWebview does not get any additional subviews
  • the UIWebView does not get any new subviews or change any isBlahBlah properties
  • [UIApplication sharedApplication] only has 1 window, and that window only has 1 view (my main view).
  • I tried the notification center thing (Notified when media player opens from UIWebView?) and did not receive notifications.

For reference, the video path I am testing with is http://trailers.apple.com/movies/fox/prometheus/prometheus-tlr1_r320i.mov

So basically my app has no way to detect that a video is currently playing. It seems like I should be able to detect, but searching around I couldn't find one. I don't need to interfere with the playback - just knowing it is playing would be fine.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Damien Del Russo
  • 1,040
  • 8
  • 19
  • 1
    OK, finally geez I've wasted an entire day on this. I found this here: http://stackoverflow.com/questions/2718606/mpmovieplayercontroller-fullscreen-movie-inside-a-uiwebview Based on that my viewController can interrogate it's self.view.subviews and if it finds a rogue memberOfClass:[UIView class] it knows something is up. What I do now is self.view bringSubviewToFront:rogueView to keep it showing. Note to UIWebView - hunting down the root view and jamming a new UIView in there is not cool! Maybe document that! Gah! – Damien Del Russo Jan 02 '12 at 06:56
  • see this https://stackoverflow.com/questions/55377677/how-to-detect-avplayer-and-get-url-of-current-video-from-wkwebview – Virani Vivek Apr 01 '19 at 12:01

0 Answers0