Closed MCJack123 closed 3 years ago
You might find some information in the README.md file for the sample metadata reader.
I'd suggest:
pbeg
-- play stream begin. No argumentspend
-- play stream end. No argumentspfls
-- play stream flush. No argumentsprsm
-- play stream resume. No arguments... you might have to experiment.
I ended up using the prsm
code to detect paused/playing state, but it seems like sometimes shairport-sync sends prsm
even if the song is being paused. Another thing is that prsm
is send after mden
, which required me to change the script to return on prsm
instead of mden
. My script sometimes sends out the metadata even though I paused the song because of this. It's not too big of a deal as it only appears for a split second, but this may need to be investigated.
That's interesting. Shairport Sync is somewhat at the mercy of whatever comes from the audio source. In the upcoming update (see the development
branch), Shairport Sync introduces an "active mode" which smooths out the transitions a bit. It has two new metadata codes -- abeg
and aend
. Not sure it's what you want, but maybe worth a look.
I spent a lot of time on this recently and tested with many sources.
My recommendation is to trigger on the status code corecaps
complemented with pbeg
and pend
.
Also to avoid unnecessary pause/play when songs change, I make sure to only execute when Duration>0, but to use the duration = 0 to latch play on the next coreastm
Hmm, not a very good explanation... I could append some code?
Case "corecaps" 'application status. Maybe 0-3: loading, playing, paused or stopped
Select Case Asc(Data)
Case 1
'hs.writelog("Airplay Status", "Playing")
If hs.GetVar("ApDuration") > 0 Then
Call Play()
Else
hs.SaveVar("ApLatch", True) 'handle Duration readiness
End If
Case 2
'hs.writelog("Airplay Status", "Paused")
Call Pause()
End Select
Exit Sub
Case "coreastm" ' SongTime
If hs.GetVar("ApLatch") = True Then Call Play() 'handle Duration readiness
Exit Sub
Case "ssncpbeg" 'play stream begins
If hs.GetVar("ApStatus") = "Paused" Then Call Play() 'fix bug
Exit Sub
Case "ssncpend" 'playstream ends
If hs.GetVar("ApStatus") = "Playing" Then Call Pause() 'fix bug
Exit Sub
`
This issue has been inactive for 60 days so will be closed 7 days from now. To prevent this, please remove the "stale" label or post a comment.
I would like to display some song information on a display only if a song is currently playing; otherwise it shows a clock. Is it possible to see if a song is playing? If so, which metadata code do I check?