kirtan-shah / nowplaying-cli

macOS command-line utility for retrieving currently playing media
GNU General Public License v3.0
148 stars 9 forks source link

Get playing state #13

Open joshstobbs opened 9 months ago

joshstobbs commented 9 months ago

Hey there! This is really great work, like many others, it seems like this tool is an answer to a long standing question for me!

Question though, is it possible to get the playing status? Like, playing or paused?

kirtan-shah commented 9 months ago

Thanks!

Unfortunately there is no such property to my knowledge. I wanted this functionality (if playing then pause media) but I got around it by just pausing (since the pause command doesn't do anything to already paused media)

Another solution I could suggest is sampling the elapsedTime after a delay and checking if it differs. I'm debating whether it would make sense to add this feature to the utility

nyxaria commented 9 months ago

For some applications (like Spotify) the elapsedTime method doesn't seem to work :/. Do you know of a work around?

imjoshnewton commented 7 months ago

To get the playback state, I'm looking at the playbackRate. At least for AppleMusic, AppleTV, and Brain.fm in Safari, this value is 0 when paused and >= 1 when playing.