| Message |
Just to expand on what Fiendish said, I made a plugin that implements that.
You need to download and install this component into Foobar2000.
Then:
 |
To save and install the Foobar2000_track_playing plugin do this:
- Copy the code below (in the code box) to the Clipboard
- Open a text editor (such as Notepad) and paste the plugin code into it
- Save to disk on your PC, preferably in your plugins directory, as Foobar2000_track_playing.xml
- The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file Foobar2000_track_playing.xml (which you just saved in step 3) as a plugin
- Click "Close"
- Save your world file, so that the plugin loads next time you open it.
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Foobar2000_track_playing"
author="Nick Gammon"
id="cd346c228c0e8479480c933d"
language="Lua"
purpose="Shows which track you are listening to"
date_written="2020-11-17 20:58:28"
requires="5.00"
version="1.0"
>
</plugin>
<!-- Timers -->
<timers>
<timer name="ShowTrack"
script="ShowTrack"
enabled="y"
second="5.00" >
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
http = require "socket.http"
require "json"
-- With thanks to Fiendish for suggesting the code below
oldTrack = nil
oldState = nil
playing = nil
function ShowTrack (name)
local page, _, _ = http.request("http://localhost:8880/api/query?player=true&trcolumns=%25artist%25%2C%25album%25%2C%25title%25")
-- check Foobar2k is running
if not page and (playing or playing == nil) then
ColourNote ("orange", "", "Foobar2000 is not running")
playing = false
end -- if
-- no information? Can't decode it
if not page then
return
end -- if
-- decode the track information
local pagetable = json.decode(page)
local artist, album, track = unpack(pagetable.player.activeItem.columns)
local playback_state = pagetable.player.playbackState
if playback_state ~= oldState and playback_state == "stopped" then
ColourNote ("orange", "", "Playback stopped")
oldState = playback_state
end -- if
if track and artist then
playing = true
if track ~= oldTrack or playback_state ~= oldState then
ColourNote ("orange", "", string.format ("Now %s %s by %s from %s", playback_state, track, artist, album))
oldTrack = track
oldState = playback_state
end -- if track changed
else
playing = false
end -- if
end -- ShowTrack
]]>
</script>
</muclient>
The plugin connects to Foobar2000 every 5 seconds and checks what track is playing (if any). It then does a ColourNote to put that into your output window. You could change that to send to the MUD, for example:
Send (string.format ("chat Hey everyone! Currently %s %s by %s from %s", playback_state, track, artist, album))
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|