xenodium / ready-player

GNU General Public License v3.0
129 stars 5 forks source link

Feature request: Support MPD #13

Closed idlip closed 1 month ago

idlip commented 1 month ago

Hi, thank you for the package, it adds such a convenience and beauty with media files.

Even your posts, the new things you bring it are helpful to the emacs community!


This is a feature request, to add basic support for mpd (daemon) via mpc (client CLI) for Audio files Emacs has built-in support for mpc (mpc.el), and I'm sure ready-player can leverage it.

Key advantages would be memory efficiency, better music library for audio files.

If possible, I will also give it a try to get something working.

idlip commented 1 month ago

Ohho, might be haste. Just mpc add would do the job ig.

I misunderstood the ready-player design, as I look at it, it has general UI as player.

Now, I think of one little feature to achieve what I expect, to configure audio and video player as alist or cons like ("vlc" . "mpc")

xenodium commented 1 month ago

Hi, thank you for the package, it adds such a convenience and beauty with media files. Even your posts, the new things you bring it are helpful to the emacs community!

Nice to hear it. Thank you.

Now, I think of one little feature to achieve what I expect, to configure audio and video player as alist or cons like ("vlc" . "mpc")

At present which utility to use can be configured like:

(defcustom ready-player-open-playback-commands
  '(("mpv" "--audio-display=no")
    ("vlc")
    ("ffplay")
    ("mplayer"))
  "Command line utilities to try for playback.

Note each entry is a list, in case additional flags are needed.

Omit the file path, as it will be automatically appended."
  :type '(repeat (list string))
  :group 'ready-player)

But if I'm understanding correctly, you'd like to have different utilities to handle videos vs audio? I have some ideas on how we could go about it... Happy to share. Would you be interested in contributing a patch?

idlip commented 1 month ago

I can only think of basic if else condition for video vs audio files, and choose the cons item.

idlip commented 1 month ago

Ok, one simple way would be to have commands in single string, so cons would make sense for audio vs video choice.

For finding the executable, just split-string and car can get the first word which would be the command.

(setq player-cmds '(("mpv --audio-display=no ..." . "mpc add") ("vlc" . "vlc")))

(dolist (elem player-cmds)
  (executable-find (car (split-string (car elem)))))
xenodium commented 1 month ago

I can only think of basic if else condition for video vs audio files, and choose the cons item.

Did you have a mechanism in mind to determine video vs audio?

(setq player-cmds '(("mpv --audio-display=no ..." . "mpc add") ("vlc" . "vlc")))

I'm wondering if we should a little further and enable overriding the player either by extension, list of extensions, or a function. This would keep most things working as they are, but also give a little more flexibility. For example, maybe we don't want gifs treated as neither audio nor video?

idlip commented 1 month ago

Did you have a mechanism in mind to determine video vs audio?

In simple way, it would be define to two list for audio and video extensions. Then apply ~if~ cond to check both the cases based on file-name-extension

(setq audio-ext '("mp3" "flac"))
(setq video-ext '("mkv" "mp4"))
(cond
 ((member (file-name-extension filename) audio-ext)
  ... get the command)
 (member (file-name-extension filename) video-ext)
 ... get the command)
xenodium commented 1 month ago

Ok, setting video vs audio utilites is now possible with:

(setq ready-player-open-playback-commands
  '((ready-player-is-audio-p \"ffplay\" \"--audio-display=no\")
    (ready-player-is-video-p \"mpv\")))
idlip commented 1 month ago

Hi xenodium!

It works like charm. The commit to implement this seems not so easy as I expected hehe.

Thank you for adding the option!

idlip commented 1 month ago

For anyone who wants to use mpd as audio player.

Make sure mpd.conf starts in local socket (not address) If by systemd service, it would usually be in /run/user/1000/mpd/socket

or if you start manually, just append these lines to bind address

bind_to_address "127.0.0.1"
bind_to_address "@mpd"

You can use following command to add any audio file (even outside mpd directory) with full absolute path.

  1. systemd service mpc add -h "/run/user/1000/mpd/socket" /home/user/walker.mp3

  2. manual conf mpc add -h "@mpd" /home/user/walker.mp3

Add similar command to ready-player-open-playback-commands

xenodium commented 1 month ago

It works like charm.

Nice to hear!

Thank you for adding the option!

Welcome

xenodium commented 3 weeks ago

ps. As of https://github.com/xenodium/ready-player/commit/df6107a670eb301a5f49a7e16c5fccc17f8bf84d we can now use extensions to determine utility:

(setq ready-player-open-playback-commands
      '((("mp3" "ogg") "audacious")
        ("mpv" "--audio-display=no")
        ("vlc")
        ("ffplay")
        ("mplayer")))
idlip commented 3 weeks ago

ps. As of https://github.com/xenodium/ready-player/commit/df6107a670eb301a5f49a7e16c5fccc17f8bf84d we can now use extensions to determine utility:

Woh! This is even better, open to all!

Thank you!