简体   繁体   中英

Is it possible to play multiple sound files simultaneously (like a mix) on Apple Watch?

This is the code I am using to play a sound with AVAudioPlayerNode . It is just playing the last sound of the beats array. On iPhone, all sounds from the beats array are playing simultaneously with the same function.

-(void)playMix{
for (int i = 0; i< mix.beatsArray.count;i++) {
    beat = [[WatchBeatObject alloc] initWithFileName:mix.beatsArray[i].fileName];
    [beat.audioPlayerNode play];
    [beat.audioPlayerNode scheduleBuffer:beat.buffer atTime:nil options:AVAudioPlayerNodeBufferLoops completionHandler:^{
    }];
}

}

NB: Method initWithFileName: handles initializing and creating AVAudioPlayerNode and everything needed.

Thank you in advance.

Does that WatchBeatObject has any category option in AVAudioSession to set AVAudioSessionCategoryAmbient? If yes, set it, they would mix different sound.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM