Take the 2-minute tour ×

I'm using an AVPlayer to play various medias. I redesigned the whole player interface and I added a MPVolumeView to control output level. It works just fine, either with the slider or with the volume buttons (yje output volume is changed), but the user gets no visual indication that the volume is changing. When using the Apple's built in Video App, when you change the output volume using buttons, there is a nice hud indicating the current volume : how can I make it appear? Thanks.

share|improve this question
No one? ReallY? –  Khal Oct 17 '12 at 13:14

1 Answer 1

up vote 0 down vote accepted

As a matter of fact, it seems that the VolumeView blocks the delivery of notifications to the system. I had to use AudioSessionAddPropertyListener to make it work like this

AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange,

and the callback

// detecting outplugg of the iPhone
void audioRouteChangeListenerCallback (void                      *inClientData,
                                   AudioSessionPropertyID    inID,
                                   UInt32                    inDataSize,
                                   const void                *inData)
    CFDictionaryRef routeChangeDictionary = inData;

    CFNumberRef routeChangeReasonRef =
    CFDictionaryGetValue (routeChangeDictionary,
                      CFSTR (kAudioSession_AudioRouteChangeKey_Reason));

    SInt32 routeChangeReason;

    CFNumberGetValue (routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason);

    if (routeChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable)
        // Headset is unplugged..
        [(VideoPlayerViewController*)inClientData pause];
share|improve this answer
can u describe it briefly. I stuck on this. what is videoPlayerviewcontroller? –  venky May 30 at 14:41
The VideoPlayerViewController is the object on which I call the register callback –  Khal Jun 2 at 7:09

Your Answer


