how to stop MPMoviePlayerViewController from downloading video if the app is in background

为君一笑 提交于 2019-12-08 12:32:34

问题


I use MPMoviePlayerViewController to play some videos form the internet.

When the user presses home button and the app goes in background, the iphone still downloads a lot of information.

Can anyone recomend me how the trafic can be stopped, without disabling multitasking or calling exit(0)?

I have tried to stop the MPMoviePlayerViewController, but in some cases, when the MPMoviePlayerViewController is not fully loaded, the it doesn't respond(not the video, the MPMoviePlayerViewController).

Thanks in Advance!


回答1:


I think you should use the below delegate methods

(void)applicationDidBecomeActive:(UIApplication *)application; (void)applicationWillResignActive:(UIApplication *)application;

(void)applicationDidEnterBackground:(UIApplication *)application (void)applicationWillEnterForeground:(UIApplication *)application




回答2:


[movieplayer stop];  
movieplayer.initialPlaybackTime = -1.0;  
[movieplayer release];   

you can use this code in applicationDidEnterBackground

- (void)applicationDidEnterBackground:(UIApplication *)application {  
}  


来源:https://stackoverflow.com/questions/6042089/how-to-stop-mpmovieplayerviewcontroller-from-downloading-video-if-the-app-is-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!