Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Can Pythonista handle volume switch up-down events a for an earphone button that is plugged into an iPhone 6s?
-
Is it possible to use Pythonista APIs to get notifications for the the volume-up and volume-down switches that are on an earphone set plugged into the earphone jack of an iPhone 6s? I want to access just one button, and get up and down notifications, similar to the touch_began and touch_ended notifications for a screen button.
I am currently using tapping on the screen to control something. I have an electrical engineering background, so I can wire a button up and plug that in, while satifying the impedances for the other connections on the plug. I'd like to be able to push that button to control something, rather than having to push on the screen of the phone.
I have no idea how to do this. Note, I do not care if this also affects the audio volume. I can have the audio muted. I just want to access the up-event and down-event when the button is depressed and let go.
I found this page, but it does not appear to have the information for the volume control switches that are plugged in with earphones.
https://developer.apple.com/documentation/audiotoolbox/system_sound_services -
@technoway, would it be enough for your use case to just get the ”volume change” notification? Sample ObjC code in the answer here. Sample translation to Python in this old thread.
-
@mikael - Thank you for the reply. I could make that work, but I'd have to change the signalling method. I need both up and down events now.
I'll continue to use the screen, and I'll look for other solutions. Perhaps there's a way to signal the screen with a device attached to the phone. I'll keep looking for a solution.
-
@technoway, I am curious, why do you need up and down?
-
If you store the last volume, then the volume change would let you figure out if you went up or down...
-
And the notification fires even if you are already at the ”top”.
Might also make sense to restore the volume to what it was, to avoid always having the phone at full volume.
-
@technoway did you ever get this working? I need something similar. Could you post the code?