Wednesday, November 11, 2026
HomeiOS Developmentios - Swift. Attempting to alter quantity by UISlider with MPVolumeView. In...

ios – Swift. Attempting to alter quantity by UISlider with MPVolumeView. In debug space writes – [MediaRemote] No native output machine out there

[ad_1]

Okay. I am making an attempt to alter quantity by my customized UISlider.

I’ve Participant (ViewController), and inside I can see movies from Youtube, so additionally have management buttons and quantity Slider !

I could not even think about that it will not be that simple. Why!?

I discover with resolution after all with MPVolumeView. However in debug space it writes – ‘[MediaRemote] No native output machine out there:’

I’ve regarded via a variety of webpages. So as a result of I am newbie I do not see the answer.

Please, see my code and inform me pls the place I am improper or not full ?!

I perceive I am improper, however cannot guess the place. I’ve too little expertise but. However I am making an attempt onerous.

.
See particulars from code (if want some extra, pls inform me)
.

lazy var soundSlider: UISlider = {
    let slider = UISlider()
    slider.minimumTrackTintColor = .white
    slider.maximumTrackTintColor = #colorLiteral(purple: 0.8039215803, inexperienced: 0.8039215803, blue: 0.8039215803, alpha: 0.7)
    slider.setThumbImage(UIImage(named: "Round_Thumb_VolumeBar"), for: .regular)
    slider.translatesAutoresizingMaskIntoConstraints = false
    
    slider.addTarget(self, motion: #selector(handleVolumeSliderChange), for: .valueChanged)
    
    return slider
}()

@objc func handleVolumeSliderChange() {
    print(soundSlider.worth)
    
    MPVolumeView.setVolume(soundSlider.worth)
}

extension MPVolumeView {
static func setVolume(_ quantity: Float) {
    
    let volumeView = MPVolumeView()
    let volumeSlider = volumeView.subviews.first(the place: { $0 is UISlider }) as? UISlider
    
    DispatchQueue.important.asyncAfter(deadline: DispatchTime.now() + 0.01) {
        volumeSlider?.worth = quantity
    }
    
}

}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments