2

I'm using this method to set the volume device programmatically:

    self.mpVolumeView.frame = CGRectMake(0, 0, self.view.bounds.width * 0.82, CGFloat(50))
    self.mpVolumeView.showsRouteButton = false
    self.mpVolumeView.showsVolumeSlider = true
    self.mpVolumeView.backgroundColor = UIColor.clearColor()

    for subview in self.mpVolumeView.subviews {
        if (subview as UIView).description.rangeOfString("MPVolumeSlider") != nil {
            // Set volume

            volumeSlider = subview as UISlider
            subview.setValue(0.5, animated: false)
            break
        }
    }

This works fine but every time I set the slider value the volume hud appears, is there a way to prevent this?

DrCachetes
  • 954
  • 1
  • 9
  • 30

1 Answers1

2

You have to add mpVolumeView as a subview of your main view and set alpha to 0.000001 because 0 doesn't work for some strange reason:

view.addSubview(mpVolumeView)
mpVolumeView.alpha = 0.000001
SebyDrax
  • 66
  • 5