Is it possible to read the state of the "play" button inside a music app's notification and use it as an event to activate/deactivate a Tasker profiles?
I need to run certain commands when playback starts or stops in a music app. I think Tasker can use notifications from specific apps as events for activating its profiles, or even look for specific text in the notifications. But can it respond to the media buttons in the music player's notification, or in the music app itself? I cannot use the %atmusicplaying variable from Autotools plugin or similar approaches to check if music is playing, because I use the device to stream the music over DLNA and for some reason the device doesn't return the music state as "playing" in this case (see another question and its answer's comments).
adb shell dumpsys activity
to find out if an intent is sent when the play/pause media button is pressed in the notification for your app. If yes, you can configure Tasker to intercept that intent and run a task. Alternatively, AutoInput might be configured to detect taps for the notification and run a task. See if any of this works.adb shell dumpsys activity
there are no timestamps, so I can't just search by the time I pressed the play/pause button. But I found some repeating patterns, like this one:#47: BroadcastRecord{303c389 u0 com.n7mobile.upnpplayer.RECEIVE_POSITION_CHANGE}act=com.n7mobile.upnpplayer.RECEIVE_POSITION_CHANGE flg=0x10 (has extras)
adb logcat -v long,descriptive
.n7.UpnpAVTransport: state PLAYING
,12-03 18:55:08.207 +0000 9692 9692 D n7.UpnpAVTransport: state STOPPED' or
n7.ServiceUpnp#api: current state: -1,
n7.ServiceUpnp#api: current state: 1`. Reading these values should do the job to enable/disable profiles. Now just have to figure out how to monitor and read them with Tasker, if it's possible.