beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.75k stars 1.82k forks source link

play plugin removes playlist too quickly #1337

Closed shanemikel closed 9 years ago

shanemikel commented 9 years ago

It's deleting the playlist before i'm done with it.

Anyway, If y'all can add a sleep for 1 second or so right before the tmp .m3u file is removed that'd be cool.

brunal commented 9 years ago

What do you mean "before you're done with it"? The m3u file is given to the command you configured, and deleted once that command has returned. There is no reason to wait 1 second before removing it.

Could you explain your use case? And post your configuration??

sampsyo commented 9 years ago

I'd guess @shanemikel is using a command that forks into the background and returns immediately. If that's the case, I'd recommend either looking for a synchronous version of the command or using a tiny wrapper script that adds the sleep you need (if sleeping seems like the only option):

#!/bin/sh
my_player $@
sleep 2
brunal commented 9 years ago

@shanemikel How does that work for you? It's been a month so I'm closing the issue, but please comment if you're not satisfied.

shanemikel commented 9 years ago

!/bin/bash

mocp -scx 2>/dev/null 1>&2 gnome-terminal --window-with-profile=Translucent -x \ mocp -T transparent-background "$1" 2>/dev/null 1>&2 &

This is what my script looks like, I've tried to write it without killing the mocp server at the beginning, as well as with and without sleeping. The only fixes I could come up with was adding a short sleep to the beetslib/play.py right before removing the tmp playlist, or copying the playlist at the beginning of my script and removing it at the end on my own.

I figured the change to the play plugin might help others using mpd or other audio servers with beets. In any case, it doesn't do any harm.

sampsyo commented 9 years ago

Yeah—since you have a script doing the work already, adding the sleep in the script makes a lot of sense to me.

shanemikel commented 9 years ago

Sleeping in the script doesn't work, I have to cp the playlist

sampsyo commented 9 years ago

Odd—it doesn't work to start the player, background it, and then sleep? I don't quite see how putting a sleep in the plugin would be any different from that.

shanemikel commented 9 years ago

Well anyway, heres my workaround

#!/bin/bash

newtmp=${1%.m3u}.cp.m3u
cp $1 $newtmp

mocp -scx 2>/dev/null 1>&2
sleep 0.5s

(sleep 1 && rm -f $newtmp) &
xfce4-terminal -x mocp -T transparent-background $newtmp 2>/dev/null 1>&2 &