sailfish-spotify / hutspot

Spotify Controller for SailfishOS. Documentation: https://sailfish-spotify.github.io/hutspot.
MIT License
18 stars 12 forks source link

Pause playback when headphones get unplugged #46

Open ksiazkowicz opened 5 years ago

ksiazkowicz commented 5 years ago

When using Librespot locally, user might expect their music to be paused after headphones get unplugged. This is not currently the case.

wdehoog commented 5 years ago

Same goes for disconnecting a bluetooth headset. Is there a DBus event we might listen to?

wdehoog commented 5 years ago

Found a DBus event for headphone. See https://github.com/sailfish-spotify/hutspot/pull/51/commits/80522fe37f0fcfb9d3221d5d78684f1268efc0e5

abranson commented 5 years ago

I think this is usually done with audio policies.

wdehoog commented 5 years ago

@abranson I don't know much about those policies. I thought they were meant to give access or not. How can we use them to detect disconnection of a headphone or headset to pause playing?

abranson commented 5 years ago

I will find that out next week - am away this weekend. Other Sailfish music players do it though I think.

abranson commented 5 years ago

Ok, so it's usually done inside QtMultimedia - the resource is lost and there's a signal to catch. But as you're not using that, the fallback is to listen for the routeChanged like you did in #51.

wdehoog commented 5 years ago

Code is in to pause on route changed to speaker. It works for the audio jack but not for bluetooth. It appears for bluez5 (which my phone uses) you need to run mpris-proxy (from bluez5-tools package) for it to work.