を知らせ、それはMixWithOthersを使用してのように見えていますキー。また、音声ルートが最後/現在のオーディオのルートに設定されていることを確認する必要があります...
FYIこれには、AudioQueueインタフェース
で私たちです...
のiPod と
/スタート音楽/
- で我々のアプリを起動しAudioQueueNewInput
- AudioQueueAddPropertyListener
- AudioQueueAllocateBuffer(S)
- AudioQueueEnqueueBuffer(S)
- setupCat
- setupDuck
- setupAudioRoute
- setupMixing
- AudioSessionSetActive(真)
- AudioQueueStart
typedef union
{
OSStatus propertyResult;
char a[4];
} unionstatus;
unionstatus u2;
typedef union
{
UInt32 UI32sessionCat;
char a[4];
} unionuint32;
unionuint32 usc2;
bool setAudioUInt32 (UInt32 property, UInt32 value)
{
bool result = true;
UInt32 UI32 = value;
UInt32 UI32size = sizeof(UI32);
u2.propertyResult = AudioSessionSetProperty (property, UI32size , &UI32);
if (u2.propertyResult)
{
printf("Error Set %ld %lx %c%c%c%c\n",u2.propertyResult,u2.propertyResult,u2.a[3],u2.a[2],u2.a[1],u2.a[0]);
result = false;
}
return result;
}
UInt32 getAudioSettingInt (UInt32 value)
{
UInt32 I32;
UInt32 I32size = sizeof(I32);
u2.propertyResult = AudioSessionGetProperty (value , &I32size, &I32);
if (u2.propertyResult)
printf("Error Get %ld %lx %c%c%c%c\n",u2.propertyResult,u2.propertyResult,u2.a[3],u2.a[2],u2.a[1],u2.a[0]);
return (I32);
}
/// checking taken out
bool otherPlaying = getAudioSettingInt (kAudioSessionProperty_OtherAudioIsPlaying);
if (otherPlaying)
{
setAudioUInt32 (kAudioSessionProperty_OtherMixableAudioShouldDuck, false);
// this returns a string, arg, have to look for string values, etc.
UInt32 audioRoute = getAudioSettingInt (kAudioSessionProperty_AudioRoute);
CFStringRef ar = (CFStringRef) audioRoute;
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
const char *car = CFStringGetCStringPtr(ar,encodingMethod);
CFRange range = CFStringFind(ar,CFSTR("Headphones"),kCFCompareCaseInsensitive);
if (range.length == 0) // we have speakers
result = setAudioUInt32 (kAudioSessionProperty_OverrideAudioRoute, kAudioSessionOverrideAudioRoute_Speaker);
else // we have headphones
{}
}
あなたもオーディオルートが最後に設定されていることを確認する必要があります/現在のオーディオルート...最後に/現在のルートを取得しますか? – loretoparisi