jeff-hughes / shellcaster

Terminal-based podcast manager built in Rust
GNU General Public License v3.0
199 stars 13 forks source link

Implement an in-app player #30

Closed tuxiqae closed 3 years ago

tuxiqae commented 3 years ago

Wondering whether you'd be willing to implement a media player in the app. I think that it'd be much nicer to not open VLC and instead just do it all from inside of ShellCaster.

jeff-hughes commented 3 years ago

I've answered this elsewhere (in the middle of a discussion about several things), but at this point I am not particularly interested in implementing a media player in the app. That would add a lot of additional complexity, and I think reduce some of the flexibility of being able to send a file/URL to whatever player you wish.

I can certainly appreciate the desire for this, but I'd rather have shellcaster do one thing well rather than try to add in too much and maybe suffer in terms of quality. That's not an absolute hard "no", but at this point I'm not convinced that adding in a hard dependency for media playback as well as adding in the additional complexity of displaying playback info on the screen, handling user inputs for play/pause/seek, etc., is worth it.

a-kenji commented 3 years ago

If you use mpv you can make it almost feel like shellcaster has internal support for the files.

An example play/pause on p configuration:

SANFILE="$(detox "$(basename "$1")")"
SOCKETNAME="/tmp/mpvsocket""$SANFILE"

_toggle(){
echo '{"command":["cycle","pause"]}' | socat - "$SOCKETNAME"
}

_toggle "$1" || mpv \
    --input-ipc-server="$SOCKETNAME" \
    "$1"

Change the $1 to %s if you want to write it directly into the configuration file, or call the script with %s.

Warning! Depends on detox (not strictly needed) & socat (needed).

If your mpv supports mpdris you will most likely be able to integrate it quite well with your DE of choice, if it doesn't have mpdris support already in order to use common playback functionality, or call shellcaster in tmux and have the status bar communicate mpdris information to you.

You can also add the --no-video flag for no video.