0

私は現在どのように

a) Play a sound next to iPod/Other music sources
b) beeing able to control the volume of that played sound (only)
c) **important** both combined!!
d) all of it also on background/mt

a )のAudioSessionとb)のMPVolumeViewの両方を使用して、sepperateを実行できます。

今私は、AudioSessionsの音量がシステムの音量に基づいているため、AudioSessionsの音量を設定できないことを読みました。これは私のベースでは悪いことです。音量調節された再生中にiPodの音楽を停止すると、さらに悪いことになります。

たとえば、runmeter(例として広告したくない)にはスライダーがあり、システムの音量やiPodの音量に関係なくアプリの音量を制御していることに気付きました。

だから私は電話をほぼミュートし、iPodを真ん中にして、アプリの音量を最大化することができます-正常に動作します。

アップルに落とされることなくこれを行う方法/ヒントはありますか?

助言がありますか?

ありがとう。


編集:これを解決してくれたbadgrrのおかげで、私の最終的な解決策は、CocosDenshinを使用することでした:

appDelegate、applicationDidEnterBackground:

[[CDAudioManager sharedManager] setMode:kAMM_MediaPlayback];
[[CDAudioManager sharedManager] setResignBehavior:kAMRBDoNothing autoHandle:NO];

appDelegate、applicationWillEnterForeground:-念のために!

[[CDAudioManager sharedManager] setResignBehavior:kAMRBDoNothing autoHandle:NO];

再生、私はまた、サウンドファイルがいつ行われたかを知る必要がありました。次を再生するために、私は同時の混合で文を構築したくないので。言葉。「こんにちは」そして「世界」と言うように:

Soundplayerの初期化について:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&err];
[[CDAudioManager sharedManager] setMode:kAMM_MediaPlayback];
soundEngine = [[CDAudioManager sharedManager] audioSourceForChannel:kASC_Right];
soundEngine.delegate = self; // ensure to implement <CDLongAudioSourceDelegate>  

サウンドの再生:

- (void)playSound:(NSString *)soundFile
{   
 [soundEngine load:[NSString stringWithFormat:@"%@.caf",soundFile]];
 [soundEngine play];
 ....
}

現在停止した後、次のものを再生します(私のaudioQueueはNSMutableDictionayです)

- (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource
{
    if ([self.audioQueue count] > 0) 
    {
        [self.audioQueue removeObjectAtIndex:0];
    }

    if ( [self.audioQueue count] > 0 ) 
    {
        NSString *file = [self.audioQueue objectAtIndex:0];
        [self playSound:file];
    } 
    else 
    {
        //NSLog(@"SoundsManager::cdAudio.. Done, queue empty");
            [self resumeIPod];
    }
}

それが私と同じ問題を抱えている人の助けになることを願っています!

4

1 に答える 1

1

コメントから回答に移動して、他の人が読みやすくするようにします。

CocosDenshionをご覧ください。サウンドにOpenALを使用し、別のインターフェイスで制御されるバックグラウンドサウンドで再生できます。必要に応じて、Cocos2dを使用せずに使用することができます。

効果音がiPodライブラリの再生を停止しないようにするには、次の行でカスタムオーディオセッションを指定する必要があります。

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:NULL];
于 2011-04-15T09:33:45.717 に答える