1
MPMoviePlayerController를 사용하여 비디오의 사운드를 백그라운드에서 재생하고 싶습니다. 지나간 비디오는 실행 중이지만 배경음은 멈 춥니 다. 나는 소리와 배경을 계속하고 싶다. (배경 소리만으로). 의 Info.plist는 "오디오"MPMoviePlayerController 백그라운드에서 재생
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (void)Play_Video{
[[AVAudioSession sharedInstance] setDelegate: self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
self.movieController = [[MPMoviePlayerController alloc] init];
self.movieController.view.frame = self.view.bounds;
self.movieController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
self.movieController.backgroundView.backgroundColor = [UIColor clearColor];
self.movieController.view.hidden = NO;
self.movieController.controlStyle = MPMovieControlStyleEmbedded;
[self.view addSubview:self.movieController.view];
self.movieController.useApplicationAudioSession = NO;
[UrlBlock VideoURL:url success:^(NSURL *URL) {
if (self.movieController)
self.movieController.contentURL = URL;
else
self.movieController = [[MPMoviePlayerController alloc] initWithContentURL:URL];
} failure:^(NSError *error) {
[self performSelectorOnMainThread:@selector(Alert:) withObject:error waitUntilDone:NO];
}];
}
는 응답 주셔서 감사합니다. 나는 아직 객관적인 프로그래밍에 익숙하지 않다. 블록을 호출하기 위해 추가되었지만 여전히 작동하지 않았습니다. 잠긴 화면을 지나면 소리가 멈 춥니 다. 네가 나를 도와 주시면 감사하겠습니다. – user1669335
통화를 중단 할 수는 없지만 통화 종료 후 비디오 또는 사운드를 재생할 수 있습니다 – GhostRider