Hi,
This isn't particularly clever, but I just found out it was possible so
thought others might be interested.
Wanting instrumental music, I looked to see if I could stream a wireless
station like Classic FM at the shell for low overhead. mpv(1), which
I normally use for local videos, will do so.
mpv --quiet https://media-ssl.musicradio.com/ClassicFM
Whilst playing, mpv will print a change in the metadata when it occurs.
When a tune starts, not long after mpv prints
icy-title: Hector Berlioz - Symphonie Fantastique Opus 14 (2)
When the tune ends, the presenter or adverts typically start, it's
printed blank.
icy-title:
A quick search showed I could have mpv mute the audio when icy-title
becomes empty, and unmute when it's not with a small script in the Lua
language placed in $HOME/.config/mpv/scripts/mute-on-icy-title.lua.
function mute_on_icy_title(name, value)
if value == "" then
mp.set_property("mute", "yes")
print("mute")
else
mp.set_property("mute", "no")
print("unmute")
end
end
mp.observe_property("metadata/icy-title", "string", mute_on_icy_title)
This file gets run every time mpv is started. It registers the
mute_on_icy_title() function to be called whenever the
metadata/icy-title property changes. That function decides whether to
mute each time its called.
It sufficed for a couple of hours of listening. I still manually hit
‘m’ in mpv's terminal to mute when the talking started but the blank
icy-title lagged, but the music came back on the property-triggered
unmute. And the logic isn't great: it should only unmute if it muted as
I may have wanted even the music muted and manually muted; but then
I couldn't mute the talking early.
Anyway, an interesting corner I didn't know about.
--
Cheers, Ralph.
--
Next meeting: Online, Jitsi, Tuesday, 2026-10-06 20:00
Check to whom you are replying
Meetings, mailing list, IRC, ... https://dorset.lug.org.uk
New thread, don't hijack: mailto:[email protected]