Created
June 30, 2012 13:44
-
-
Save stevenhuey/3023792 to your computer and use it in GitHub Desktop.
Set the audio mix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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