Hi Martin,
we have "Music Active" condition, would it be possible to add "music active" trigger?
To activate a flow once [any] music is playing (no matter what player/application)
Thanks.
Music Active Trigger
Moderator: Martin
Re: Music Active Trigger
Hi,
I have not yet found an API in Android that allows to detect this event and I don't like to fall back to a polling mechanism at the moment.
Some music players send broadcast intents you can capture with trigger General Broadcast but not all media players do this as far as I know.
Regards,
Martin
I have not yet found an API in Android that allows to detect this event and I don't like to fall back to a polling mechanism at the moment.
Some music players send broadcast intents you can capture with trigger General Broadcast but not all media players do this as far as I know.
Regards,
Martin
Re: Music Active Trigger
You can watch for a general broadcast "com.android.music.playstatechanged". This is fired whenever some (compatible) app starts or stops playing music.
Then read out the new state via the "playing" extra:
(If a song is playing, there are probably more extras, e.g. song, album, artist, etc.. See here.)
This works for Play Music and Pocket Casts for me. Didn't test with other apps.
P.S.: Other apps seem to use different broadcasts, see here for a list.
Then read out the new state via the "playing" extra:
Code: Select all
isPlaying = getBoolean("playing", false);
This works for Play Music and Pocket Casts for me. Didn't test with other apps.
P.S.: Other apps seem to use different broadcasts, see here for a list.
BlackBerry KEY2, Android 8.1.0