问题
I am developing an iPhone application which plays the video using MPMoviePlayerController
. When I switch to background(device with multi-tasking support), the video play is paused and when I bring my app to foreground video play is resumed.
But, when I switch to foreground I do not want my video to be resumed. I tried to pause the MPMoviePlayerController
in the method applicationWillEnterForeground. But, I think they resume implicitely after call to applicationWillEnterForeground
. Is there any notification methods that corresponds to applicationDidEnterForeground
OR applicationWillEnterBackground
?
回答1:
Although as you know UIApplicationDidEnterForegroundNotification
and UIApplicationWillEnterBackgroundNotification
do not exist, there are functions that correspond to the same thing.
They are,
UIApplicationDidBecomeActive
:
and
UIApplicationWillResignActive
:
回答2:
Check out the UIApplication Class Reference here: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728
In the notifications section of that document, you'll find the notifications posted to the Notification center. Your class can register to receive these notifications and handle the video playback state appropriately.
Hope this is the answer you were looking for.
来源:https://stackoverflow.com/questions/6703544/do-not-resume-mpmovieplayercontroller-when-application-enters-foreground