Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applicationMusicPlayer volume notification

I am using an applicationMusicPlayer and when i try to change the volume appear the visual notification, as shown in the picture. Here the code I am using:

[MPMusicPlayerController applicationMusicPlayer] setVolume:newVolune];

Anyone knows how to hide this notification?

enter image description here

like image 470
mt81 Avatar asked Oct 23 '11 19:10

mt81


2 Answers

I don't know where the docs says so, but if you add a MPVolumeView view to your app the system volume overlay goes away. Even if it is not visible:

- (void) viewDidLoad 
{
    [super viewDidLoad];
    MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame: CGRectZero];
    [self.view addSubview: volumeView];
    [volumeView release];
    ...
}

You can use the hardware volume buttons, the setVolume method or directly interact with the control (if visible) that the overlay doesn't show up.

like image 82
djromero Avatar answered Nov 20 '22 08:11

djromero


For iOS6 I had to set an image with alpha 0 and non-zero size to the MPVolumeView's image fields in order to get the default volume change notification to disappear.

// hide the hardware volume slider
UIImage *thumb = [[UIImage alloc] initWithCIImage:[UIImage imageNamed:@"volumeHider"].CIImage scale:0.0 orientation:UIImageOrientationUp];
MPVolumeView *hwVolume = [[MPVolumeView alloc] initWithFrame:self.frame];
[hwVolume setUserInteractionEnabled:NO];
hwVolume.showsRouteButton = NO;
[hwVolume setVolumeThumbImage:thumb forState:UIControlStateNormal];
[hwVolume setMinimumVolumeSliderImage:thumb forState:UIControlStateNormal];
[hwVolume setMaximumVolumeSliderImage:thumb forState:UIControlStateNormal];
[self addSubview:hwVolume];

This made the MPVolumeView be "visible" on the screen, but invisible to the user.

like image 4
zbrunson Avatar answered Nov 20 '22 07:11

zbrunson