Skip to content

Instantly share code, notes, and snippets.

@stevenhuey
Created June 30, 2012 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenhuey/3023792 to your computer and use it in GitHub Desktop.
Save stevenhuey/3023792 to your computer and use it in GitHub Desktop.
Set the audio mix
// Build and apply an audio mix using our volume values
- (void)applyAudioMix
{
AVMutableAudioMix* mix = [AVMutableAudioMix audioMix];
NSMutableArray* inputParameters = [[NSMutableArray alloc] initWithCapacity:0];
[_audioMixTrackIDs enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL*stop) {
AVAssetTrack* track = [self trackWithId:(CMPersistentTrackID)[(NSNumber*)obj integerValue]];
AVMutableAudioMixInputParameters* params = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:track];
[params setVolume:[[_audioMixValues valueForKey:key] floatValue]
atTime:kCMTimeZero];
[inputParameters addObject:params];
}];
mix.inputParameters = inputParameters;
_player.currentItem.audioMix = mix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment