You can change the volume during playback using the method described here:
http://developer.apple.com/library/ios/#qa/qa1716/_index.html
While the text of the article seems to suggest that it can only be used to mute the sound, you can set the volume to whatever you want, and you can set it after playing the sound. For example, if your AVAsset instance is called โasset,โ your AVPlayerItem instance is called โplayerItem,โ and the volume you want to install is called โvolume,โ the following code should do what you want:
NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio]; NSMutableArray *allAudioParams = [NSMutableArray array]; for (AVAssetTrack *track in audioTracks) { AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters]; [audioInputParams setVolume:volume atTime:kCMTimeZero]; [audioInputParams setTrackID:[track trackID]]; [allAudioParams addObject:audioInputParams]; } AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix]; [audioMix setInputParameters:allAudioParams]; [playerItem setAudioMix:audioMix];
Jesse Crossen May 30 '11 at 16:57 2011-05-30 16:57
source share