Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Is this possible... ?

Is this possible... ?

Posting of new messages is disabled at present.

Refresh page


Posted by Tralfaz   (2 posts)  Bio
Date Sun 15 Nov 2020 08:45 PM (UTC)
Message
IF it's possible, I want to have Mushclient import the currently playing artist/album from Foobar2K on Win10 to an &info on ShangrilaMUSH. I know that may not be doable, but I know juuust enough to think it could be. I need advice, if you can help. I'm not a coder, and not finding any preexisting posts that relate.
Thanks.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 16 Nov 2020 02:44 AM (UTC)
Message
I don't know enough about Foobar2K to know if it is doable or not. I doubt it, somehow. You would need to query Foobar2K via some API, which may or may not be possible.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tralfaz   (2 posts)  Bio
Date Reply #2 on Mon 16 Nov 2020 03:57 AM (UTC)
Message
Of the music player progs I've tried, Foobar2K appears to be very much open-source, and configurable. My problem is that I think it may be possible to do what I desire, but I'm not gonna be he who does it. My programming stopped after the early 90's. I've looked at Mushclient helps, and at those for Foobar2K, and those for ShangrilaMUSH. Gave me a headache!

It's just for fun, something to play wif. The helps of all three are overwhelming for this ol' fart.

I've got $100 for anyone that can make it work. Money's easy, neurons are hard. And old. But, life ain't boring! I'm leaving it all on the field.

Seriously, thanks for taking a look at it, you're a good human bean. :) Stay safe, y'all.

-Tralfaz
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #3 on Mon 16 Nov 2020 04:04 AM (UTC)

Amended on Mon 16 Nov 2020 04:05 AM (UTC) by Fiendish

Message
Maybe you can install the https://github.com/hyperblast/beefweb foobar2k plugin to set up an HTTP API for foobar and then query it from MUSHclient using luasocket.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 16 Nov 2020 07:18 AM (UTC)
Message
That sound plausible, in principle. But as the OP isn't a coder someone is going to have to show the technique ...

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #5 on Mon 16 Nov 2020 05:41 PM (UTC)

Amended on Tue 17 Nov 2020 06:42 AM (UTC) by Fiendish

Message
Add this component to foobar2k: https://github.com/hyperblast/beefweb/releases/download/v0.4/foo_beefweb-0.4.fb2k-component

And then in MUSHclient you can do this using Lua:


http = require "socket.http"
require "json"

local page, _, _ = http.request("http://localhost:8880/api/query?player=true&trcolumns=%25artist%25%2C%25album%25%2C%25title%25")
local pagetable = json.decode(page)

local artist, album, track = unpack(pagetable.player.activeItem.columns)
local playback_state = pagetable.player.playbackState

print(artist, album, track, playback_state)


Quote:
I've got $100 for anyone that can make it work

paypal.me/mushclientfiendish :)

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #6 on Tue 17 Nov 2020 09:52 PM (UTC)

Amended on Tue 17 Nov 2020 10:12 PM (UTC) by Nick Gammon

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:

Template:saveplugin=Foobar2000_track_playing To save and install the Foobar2000_track_playing plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. 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.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Foobar2000_track_playing.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. 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

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #7 on Fri 20 Nov 2020 12:15 AM (UTC)
Message
I'm still waiting to see if they pay the $100. ^_^

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #8 on Mon 23 Nov 2020 03:31 AM (UTC)
Message
Note that without Foobar2000 running this plugin seems to degrade keyboard input significantly. I suspect that it is attempting to connect to the (local) web server, and hanging for a couple of seconds, then timing out.

Only install the plugin if you are actually planning to use Foobar2000.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #9 on Mon 23 Nov 2020 04:09 PM (UTC)
Message
They can also google "luasocket asynchronous http.request" or something.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #10 on Sun 06 Dec 2020 09:45 PM (UTC)
Message
Still no $100 :(

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,819 views.

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.