0

So I am streaming a video file with audio using AVPlayer and have a UIWebView overlayed over the video that has controls for play/pause, seek, ect. I also have a slider for volume that I am trying to implement but so far I haven't had any luck. Here is my code the change the volume:

- (void)setPlayerVolume:(float)volume
{
    NSArray *tracks = [self.player.currentItem.asset tracksWithMediaType:AVMediaTypeAudio];
    NSMutableArray *audio = [NSMutableArray array];

    for (AVAssetTrack *track in tracks) {
        AVMutableAudioMixInputParameters *input = [AVMutableAudioMixInputParameters audioMixInputParameters];
        [input setVolume:volume atTime:kCMTimeZero];
        [input setTrackID:track.trackID];
        [audio addObject:input];
    }

    AVMutableAudioMix *mix = [AVMutableAudioMix audioMix];
    [mix setInputParameters:audio];
    [self.player.currentItem setAudioMix:mix];
}

I have been reading up, and it seems like the only solution to use MPVolumeView. Are there any other solutions?

Thanks for any help, its greatly appreciated.

Pat
  • 649
  • 1
  • 8
  • 24
  • Did you overlook the AVPlayer `volume` property? Just set it some float value between 0.0 (mute) and 1.0 (max). – Gerd K Jun 09 '14 at 23:46
  • I am currently building for iOS 6 so I dont have access to that property. – Pat Jun 10 '14 at 13:50

0 Answers0