내 질문에 대해 유감스럽게 생각하지만 intro-video를 구현했으며 내 iPad의 하드웨어 자동 스위치에도 불구하고 오디오가 재생 중입니다. 짧은 사운드 샘플 재생 전용 AVAudioplayer 내 응용 프로그램 내에서 사용하고 있습니다. 이 클래스 내에서 "AVAudioSessionCategory"를 설정 한 유일한 영역입니다. 하지만 모든 오디오 재생에 대해서만 청취 할 수있는 부분이 없습니다. 내 소개 비디오 전용입니다.무음 모드에도 불구하고 동영상의 오디오 재생이 가능합니까?
"오디오 버그"를 수정하여 무비 플레이어가 소리를 지르지 않도록하는 방법에 대한 도움이 필요하십니까? 감사합니다 당신에게
Here's 내 오디오 - 클래스 :
- (id)initWithSoundfileName:(NSString*) file
{
if ((self = [super init]))
{
NSString* filename = [file stringByDeletingPathExtension];
NSString* fileextension = [file pathExtension];
// get file path from bundle
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: filename ofType: fileextension];
NSLog(@"AudioPlayer init: %@", soundFilePath);
NSURL* fileurl = [[NSURL alloc] initFileURLWithPath:soundFilePath];
NSError* error = nil;
AVAudioPlayer* audioplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileurl error:&error ];
if (error) { NSLog(@"Error creating AVAudioPlayer %@", [error description]);}
// set audio policy
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:NULL];
self.player = audioplayer;
[self.player prepareToPlay];
[self.player setDelegate:self];
}
return self;
}
-(void) play{
[self.player play];
}
그리고 내 비디오 재생 방법 here's :
- (void)playIntroVideo
{
NSString *movpath = [[NSBundle mainBundle] pathForResource:@"mymovie" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:movpath];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
self.moviePlayerController.fullscreen = YES;
self.moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
self.moviePlayerController.controlStyle = MPMovieControlStyleNone;
self.moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
self.moviePlayerController.useApplicationAudioSession = NO;
[self.moviePlayerController.view setFrame: self.view.bounds];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.moviePlayerController];
[self.view addSubview:self.moviePlayerController.view];
[self.moviePlayerController prepareToPlay];
[self.moviePlayerController play];
}
왜 'useApplicationAudioSession'을'아니오 '로 설정하고 있습니까? – Till
나는 같은 문제를 가지고 있기 때문에 : http://stackoverflow.com/questions/10773198/mpmovieplayerviewcontroller-observes-serverconnectiondiednotification%C2%A0. 하지만이 속성을 "true"로 설정하면 오디오 재생이 올바르다 !! 감사. 위에 설명 된 문제에 대해 살펴 보겠습니다. 고마워요 – geforce