Http Live Streaming에 있는 Sample Streams에 있는 URL이 잘 동작하지 않아서 아래 것으로 해보니 잘 된다.
http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8
Ref: http://stackoverflow.com/questions/2192195/iphone-live-video-stream-media-player
This is a simple process:
Now your applicationwillterminate: method will be run when the user taps the home key, and your app will exit for real.
아래 PG의 내용처럼 background로 진입하지 않고, 앱이 종료하고 예전처럼 applicationWillTerminate: 이 불려지게 됩니다.
하지만 Philosup님께서 이야기한 것처럼 홈 버튼을 두 번눌렀을 때, 나타는 background app list에는 보이지만, 앱이 완전 종료되었기 때문에, background app 목록에 있는 해당 앱을 클릭하면 앱이 새로 시작됩니다. 즉, fast app switch가 되지 않습니다.
그래서 XCode로 디버깅을 해보면, 앱 수행 후 홈 버튼을 누르면 XCode의 Tasks 붉은 버튼이 비활성되면서 앱이 종료됩니다.
Opting Out of Background Execution
If you do not want your application to remain in the background when it is quit, you can explicitly opt out of the background execution model by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES. When an application opts out, it cycles between the not running, inactive, and active states and never enters the background or suspended states. When the user taps the Home button to quit the application, the applicationWillTerminate: method of the application delegate is called and the application has approximately five seconds to clean up and exit before it is terminated and moved back to the not running state.
Ref: Screw Multitasking: How To Make Your iOS 4 Apps Exit For Real
iOS 3.2 부터는 MPMoviePlayer를 play하기 전에 MPMoviePlayer의 view frame을 잡아줘야한다는 apple의 Q&A 답변입니다.
Q: I’m able to successfully play movies using MPMoviePlayerController on iOS 3.1.3. When I run this same code on the iPad and on the iPhone with iOS 4 I can hear the movie audio, but the video is no longer displayed. What’s going on?
A: Starting with iPhone iOS 3.2, calling the -play: method still starts playback of the movie but it does not ensure that the movie is visible. In order to display a movie, you must get the new view property from your MPMoviePlayerController object and add that view to your view hierarchy. Here’s a code snippet:
Listing 1: How to add the MPMoviePlayerController view property to your view hierarchy to play a movie.
#import <UIKit/UIKit.h> #import <MediaPlayer/MediaPlayer.h> MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; [[player view] setFrame:[myView bounds]]; // size to fit parent view exactly [myView addSubview:[player view]]; [player play];
See Important Porting Tip for Using the Media Player Framework and the MPMoviePlayerController Class Reference for more information.
Ref: MPMoviePlayerController plays movie audio but not video
NSOperation, Notification, NSCondtion 등의 순수하게 의도된 방법을 쓰면 된다.
하지만 한 번 만들어진 앱에서 UI (때론 더러운 플로우가 엉켜있는)가 덕지 덕지 붙은 상황에서
Main run loop에서 asyn job을 기다리는 것은 여간 쉬운 일이 아닌다.
ㅎㅎ 하지만 오늘 구글 리더를 읽다 아주 나이스한 뽀록 (사실 뽀록은 아니고 API를 잘 찾아 이해해서 쓴 것이니) 팁 발견!
아주 예쁘게 기다려준다. 흑흑흑.
int i = 0;
while (i < 10)
{
// This executes another run loop.
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
i++;
}
Ref: http://blog.sallarp.com/iphone-ipad-wait-for-asynchronous-nsrunloop-task-to-complete/
runMode:beforeDate:
Runs the loop once, blocking for input in the specified mode until a given date.
- (BOOL)runMode:(NSString *)mode beforeDate:(NSDate *)limitDate
Parameters
mode
The mode in which to run. You may specify custom modes or use one of the modes listed in “Run Loop Modes.”
limitDate
The date until which to block.
Return Value
YES if the run loop ran and processed an input source or if the specified timeout value was reached; otherwise, NO if the run loop could not be started.
Discussion
If no input sources or timers are attached to the run loop, this method exits immediately and returns NO; otherwise, it returns after either the first input source is processed or limitDate is reached. Manually removing all known input sources and timers from the run loop does not guarantee that the run loop will exit immediately. Mac OS X may install and remove additional input sources as needed to process requests targeted at the receiver’s thread. Those sources could therefore prevent the run loop from exiting