6

In my application I am loading some webpages embedded with Photos and Videos. Also I am using the following notifications to manage the player,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(embeddedVideoStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(embeddedVideoEnded:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

This is working fine in iOS7, but in iOS8 its not working. Any workarounds? Thanks in advance.

christijk
  • 1,753
  • 18
  • 26

1 Answers1

4

This is one option, I have found.. The problem is that is not Will is DID become hidden..

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(embeddedVideoStarted:)
                                                 name:UIWindowDidBecomeVisibleNotification
                                               object:self.view.window];

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(embeddedVideoEnded:)
                                                 name:UIWindowDidBecomeHiddenNotification
                                               object:self.view.window];

If, I find a fix for the second notification I will posted it.. :)

valbu17
  • 4,034
  • 3
  • 30
  • 41
  • did you find a fix? DidBecomeHidden is too late for getting the orientation of the screen back... – Boaz Nov 05 '14 at 19:57
  • you can get the orientation of the back.. you might wanna take a look a [this ->](http://stackoverflow.com/questions/26611646/ios7-ios8-allow-only-portrait-in-view-controller/26612748#26612748) or [here ->](http://stackoverflow.com/questions/26694955/properly-force-or-allow-landscape-mode-for-youtube-embedded-video-in-ios-8-witho) I hope it helps! – valbu17 Nov 05 '14 at 20:16
  • I implemented such a solution, but the problem is that the supportedInterfaceOrientationsForWindow is getting called before UIWindowDidBecomeHiddenNotification. And than the screen behind the video is landscape. I need to somehow manually invoke UIWindowDidBecomeHiddenNotification – Boaz Nov 05 '14 at 20:18
  • yah, If I understand correct it's exactly how it should work.. please notice that this is only for when the video goes to fullscreen and not if you are playing the video inline. – valbu17 Nov 05 '14 at 21:49
  • It works perfectly fine for me, if you want just log the `request.URL.absoluteString` to identify which url you want to target.. or just post a question with some related code to see if I can help you better. – valbu17 Nov 07 '14 at 18:55
  • @christijk.. I have same issue.. I have a html5 embeded player but native player comes in between. Have you found any solutions to close the native thing? – Saty Jul 26 '16 at 12:10