It's working correctly if the app just become inactive/active (when some alert came or by double clicking on home button)
AVPlayer *player;
- (void)applicationWillResignActive:(UIApplication *)application
{
[player pause];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[player play];
}
If the app goes to background (by clicking home button) and comes back, it's not playing from paused position instead of that it is playing from different point (sometimes from start, sometimes from middle).
Follow below steps:
1) Firstly add
float *time
inappDelegate.h
file.2) Take
current time
inapplicationWillResignActive
3) Add below methods
ApplicationWillResignActive
methodpause
player andsave
current
time
of playerNow in
applicationDidBecomeActive
addseekToTime
You should call the this methods before application is going to background. [player pause]; or [player stop];