UIMoviePlayerControllerDidExitFullscreenNotification NSNotification not working in iOs 8 - ios

[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(youTubeStarted:) name:#"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(youTubeFinished:) name:#"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
UIMoviePlayerControllerDidExitFullscreenNotification NSNotification not working in iOs 8

i am also faced the same problem but finally ended with using UIWindowDidBecomeVisibleNotification and UIWindowDidBecomeHiddenNotification, for embedded youtube videos(assuming by looking at your selector method names)
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(enteredFullScreen:) name:UIWindowDidBecomeVisibleNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(exitedFullScreen:) name:UIWindowDidBecomeHiddenNotification object:nil];
above is a patch work around,(hope this helps)

I use MPMoviePlayerController and it works fine. I guess that depending what you are using it for, you don't need UIMoviePlayerController.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(youTubeFinished)
name:MPMoviePlayerDidExitFullscreenNotification
object:self.player.moviePlayer];

Related

Receive NSNotification method not calling

I have use below for for register notification:-
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(AllSearch:) name:filter object:nil];
-(void)AllSearch:(NSNotification *)notification
{
NSLog(#"abc");
}
and i post notification with this code:-
[[NSNotificationCenter defaultCenter] postNotificationName:filter object:nil];
But "AllSearch" Method not calling.
plz check you code you have to addObserver first
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(AllSearch:) name:filter object:nil];
befor postNotification
[[NSNotificationCenter defaultCenter] postNotificationName:filter object:nil];

NSNotificationCenter Thread breaks at second call even after it has been removed

I am using NSNotificationCenter for two different ViewControllers. First time calling NSNotificationCenter works well and after that I remove the observer. But if I run it again, the thread breaks even after removing the observer.
in ViewController1:
[[NSNotificationCenter defaultCenter] postNotificationName:#"textUpdateNotification" object: nil ];
in ViewController2:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receiveNotification:) name:#"textUpdateNotification" object:nil];
-(void)receiveNotification:(NSNotification *)notificaton
{
....
....
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"textUpdateNotification" object:nil];
}
I tried with removing the observer in - (void)dealloc there also the same thing is happening.
Try removing the observer in viewDidDisappear
-(void)viewDidDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"textUpdateNotification" object:nil];
}
Sorry for my typo,
I am removing observer in the source ViewController where I am triggering the NSNotification, I should remove it from second ViewController where its being used.
in ViewController1:
[[NSNotificationCenter defaultCenter] postNotificationName:#"textUpdateNotification" object: nil ];
in ViewController2:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receiveNotification:) name:#"textUpdateNotification" object:nil];
-(void)receiveNotification:(NSNotification *)notificaton
{
....
....
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"textUpdateNotification" object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"textUpdateNotification" object:nil];
}
Thanks for every one

UIWebView Embed video callbacks are not working in iOS8?

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.
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.. :)

Using instance methods in the app delegate

I wanted to run a instance method from my BPGameController class called "pauseGame" in my app delegate when my application enters background mode and when it resigns, and a instance method called "resumeGame" when the application becomes active again, I've tried a few different things but none have worked for me so far
In BPGameController's viewDidLoad method sign up for the notifications as follows:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(pauseGame)
name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(resumeGame)
name:UIApplicationDidBecomeActiveNotification object:nil];
When you are done remove yourself from observing.
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];

multiple notifications in MPMoviePlayerController

Is it possible to have two different playback notifications in a MPMoviePlayerController?
I want to use these:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(MPMoviePlayerPlaybackDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.moviePlayer];
i did manage to get them working but when i use them together only MPMoviePlayerPlaybackStateDidChangeNotification is called.
Please advise.

Resources