Forum Archive

Controlling System volume objc_util

dradkowski

Hi

Is there a way of controlling the system volume (not the music player volume!) from objc_util ?

Cheers

Webmaster4o

What do you mean by 'system volume', not music player volume? As far as I am aware, the system volume is the music player volume. There's the ringer volume and the music volume, but the music volume controls everything besides the ringtone.

omz

There is no Apple-sanctioned way (public API) to do this, but this works on iOS 9.2 (things like this tend to break with system updates):

from objc_util import NSBundle, ObjCClass, on_main_thread
NSBundle.bundleWithPath_('/System/Library/Frameworks/MediaPlayer.framework').load()
MPVolumeView = ObjCClass('MPVolumeView')

@on_main_thread
def set_system_volume(value):
    volume_view = MPVolumeView.new().autorelease()
    for subview in volume_view.subviews():
        if subview.isKindOfClass_(ObjCClass('UISlider')):
            subview.value = value
            break

set_system_volume(0.5)

There's probably a less convoluted way that I don't know of.

dradkowski

@Webmaster4o notifications and ringtone on iPhone

dradkowski

@omz Keep up the good work! Your apps are brilliant! :) Thanks mate!

NoBetterName

Does this work on iOS 10?

NoBetterName

Because I am looking for a way to mute the ringer volume, and then put it back to where it was.

ccc

Did you try the solution above? Did it work or not?

NoBetterName

I did, it mutes the music player volume. But if i wanted to take a picture without the click noise, I want to mute the ringer. I would turn it immediately back on so I wouldn't make confusion.

Alejandro

Descargue aquí los últimos tonos de llamada de iPhone 2022 que le brindan tonos de llamada y sonidos de notificación exclusivos y personalizados. https://descargartonosdellamada.com/