그래서 나는 설정 파일에서 바로 약간의 오디오를 재생하는 오디오 세션AVAssestReader 정지 오디오 콜백
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionSetActive(true);
UInt32 audioCategory = kAudioSessionCategory_MediaPlayback; //for output audio
OSStatus tErr = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,sizeof(audioCategory),&audioCategory);
그런 다음 설정의 어느 쪽 AudioQueue 또는 RemoteIO 설정.
AudioQueueStart(mQueue, NULL);
내 오디오가 재생되면 내 앱의 상태 표시 줄에서 '재생 아이콘'을 볼 수 있습니다. 다음에 AVAssetReader를 설정합니다.
AVAssetTrack* songTrack = [songURL.tracks objectAtIndex:0];
NSDictionary* outputSettingsDict = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
// [NSNumber numberWithInt:AUDIO_SAMPLE_RATE],AVSampleRateKey, /*Not Supported*/
// [NSNumber numberWithInt: 2],AVNumberOfChannelsKey, /*Not Supported*/
[NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsNonInterleaved,
nil];
NSError* error = nil;
AVAssetReader* reader = [[AVAssetReader alloc] initWithAsset:songURL error:&error];
// {
// AVAssetReaderTrackOutput* output = [[AVAssetReaderTrackOutput alloc] initWithTrack:songTrack outputSettings:outputSettingsDict];
// [reader addOutput:output];
// [output release];
// }
{
AVAssetReaderAudioMixOutput * readaudiofile = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:(songURL.tracks) audioSettings:outputSettingsDict];
[reader addOutput:readaudiofile];
[readaudiofile release];
}
return reader;
[reader startReading]을 호출하면 오디오 재생이 중지됩니다. RemoteIO 및 AudioQueue의 경우 콜백 호출이 중지됩니다.
내가 혼합 옵션을 추가하는 경우 : AudioQueueStart 후 오디오가 호출 될 때
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (UInt32), &(UInt32) {0});
가 그런 다음 '재생 아이콘'더 이상 나타납니다. 전화기가 나를 주요 오디오 소스로 보지 않기 때문에 다른 기능도 잠겨 있습니다.
AVAssetReader를 사용할 수있는 방법을 알고 있고 여전히 기본 오디오 소스로 남아있는 사람은 누구입니까?