Discussion:
repeat may be broken?
Storm Dragon
2015-09-25 19:19:51 UTC
Permalink
Howdy,
I need to play a track with cmus-remote, make it repeat indefinitely, then stop, remove the track, and play a new track on repeat indefinitely. I thought I had it working, but the problem is, the track keeps getting added to the queue, instead of replacing the current track. It seems like -c isn't working. My play string I came up with is:
cmus-remote -s -c -p -l trackname.opus
It almost works, but doesn't remove the first track before playing the new one, so instead of playing the new track, it just repeats the first track.
Thanks for any help
Storm
--
Powered by Arch Linux! I am registered Linux user number 508465: https://linuxcounter.net/user/508465.html
My blog, Thoughts of a Dragon: http://www.stormdragon.tk/
get my public PGP key: gpg --keyserver wwwkeys.pgp.net --recv-key 43DDC193
Twitter and Facebook are so ... yesteryear. Get your 2MB Social account TODAY! http://2mb.social/main/register
How many Internet mail list subscribers does it take to change a lightbulb? http://goo.gl/eO4PJ
"And the blood drains down like devil's rain, We'll bathe tonight."
The Misfits - Skulls
Jason Woofenden
2015-09-25 19:55:59 UTC
Permalink
Hi Storm,

First, note that cmus does not act on your commandline flags in
order, it parses them all, and then acts on them in it's own order.

This enables eg the -l flag to effect all operations (eg it makes
the -c flag clear the library).

That said... It looks like it's processing your flags in a good
order.

My first guess: The issue you're having is because files are added
to the library asynchronously (I think), thus the track you want
played is not in the library yet by the time the -p flag is acted
upon.

I suggest: using ``-f trackname.opus`` instead of ``-s -p``. That
will play that file immediately (whether it's in your library or
not). Surely by the time the track finishes, the "add to library"
part will have finished, and the repeat should work.

Another possible problem is that your cmus is not in "play from
library" mode (eg it's playing from the playlist).

Try this if you'd like to manipulate the playlist:

cmus-remote -P -c -f filename.opus filename.opus

Or this for the library:

cmus-remote -l -c -f filename.opus filename.opus

Be sure to put the filename in twice, as above. The first one is
passed to -f (play immediately) and the second for adding to the
playlist/library.

Also, be sure cmus is playing from whichever one you're
manipulating. Shift-M in cmus toggles this.
--
Jason

------------------------------------------------------------------------------
Storm Dragon
2015-09-25 21:03:43 UTC
Permalink
Howdy,
It still seems to have the same problem. I'm trying to use cmus to play background music for areas in a MUD. The code is in a tintin++ script. Here's what I have, just so you can see if what I did looks right. $backgroundMusicTrack is the name of the track that is played. The variable is passed to a system command that runs it, along with the file name, so putting $backgroundMusicTrack in the play variable would call the track twice. At least that's my theory of what it is doing lol. But, if there were a way to not have to call the filename twice, that would be cool. Here's the variables that handle cmus stuff:
#variable {bgmPlayer} {cmus};
#variable {bgmPlay} {cmus-remote -l -c -f $backgroundMusicTrack};
#variable {bgmStop} {cmus-remote -s};
#variable {bgmVolumeDown} {cmus-remote -v -5%};
#variable {bgmVolumeUp} {cmus-remote -v +5%};
#system {cmus-remote -C "set repeat=true"}
I did it this way so there can be multiple options for the background music player. So far I have moc and xmms2 working. I made cmus the default player though, because it is so much easier to configure than the others, especially when it comes to softvol.
Thanks for the help
Storm
Post by Jason Woofenden
Hi Storm,
First, note that cmus does not act on your commandline flags in
order, it parses them all, and then acts on them in it's own order.
This enables eg the -l flag to effect all operations (eg it makes
the -c flag clear the library).
That said... It looks like it's processing your flags in a good
order.
My first guess: The issue you're having is because files are added
to the library asynchronously (I think), thus the track you want
played is not in the library yet by the time the -p flag is acted
upon.
I suggest: using ``-f trackname.opus`` instead of ``-s -p``. That
will play that file immediately (whether it's in your library or
not). Surely by the time the track finishes, the "add to library"
part will have finished, and the repeat should work.
Another possible problem is that your cmus is not in "play from
library" mode (eg it's playing from the playlist).
cmus-remote -P -c -f filename.opus filename.opus
cmus-remote -l -c -f filename.opus filename.opus
Be sure to put the filename in twice, as above. The first one is
passed to -f (play immediately) and the second for adding to the
playlist/library.
Also, be sure cmus is playing from whichever one you're
manipulating. Shift-M in cmus toggles this.
--
Jason
--
Powered by Arch Linux! I am registered Linux user number 508465: https://linuxcounter.net/user/508465.html
My blog, Thoughts of a Dragon: http://www.stormdragon.tk/
get my public PGP key: gpg --keyserver wwwkeys.pgp.net --recv-key 43DDC193
Twitter and Facebook are so ... yesteryear. Get your 2MB Social account TODAY! http://2mb.social/main/register
How many Internet mail list subscribers does it take to change a lightbulb? http://goo.gl/eO4PJ
"We sail the endless oceans, we sail the raging seas. The quest is never ending, it leads us to destiny."
Alestorm- The Quest
Jason Woofenden
2015-09-25 21:14:55 UTC
Permalink
Hi Storm,

It looks like you didn't do what I suggested. Sounds like you said
that you didn't understand why my suggestion would work, so decided
not to try it. I'm not going to help you further until you try the
advice I already gave.

As I said, the first filename is an argument to the -f flag.

Is there some reason you're not doing the following?

#variable {bgmPlay} {cmus-remote -l -c -f $backgroundMusicTrack $backgroundMusicTrack};

That will _not_ add the track twice, it'll play it immediately (the
-f <filename> part) and add it to the library (the second
<filename>) for repeats.
--
Jason

------------------------------------------------------------------------------
Storm Dragon
2015-09-25 21:32:39 UTC
Permalink
Howdy,
I think I didn't do a good enough job at explaining how that works. The file name is getting passed twice. The part that actually plays the track is this:
#system {$bgmPlay $backgroundMusicTrack};
and in the case of cmus, I set the bgmPlay veriable to:
#variable {bgmPlay} {cmus-remote -l -c -f $backgroundMusicTrack};
So, it should be getting passed twice. Of course, I could be missing something you said, so just let me know if I did, but it looks to me like I have followed your instructions exactly. The reason I don't add the second $backgroundMusicTrack to the bgmPlay varaible is it would end up being called 3 times instead of 2. The other players only require the track be added once. Of course I suppose I could just add the track name into the other play commands, but that would require some changes I would rather not have to make unless absolutely necessary.
Thanks
Storm
Post by Jason Woofenden
Hi Storm,
It looks like you didn't do what I suggested. Sounds like you said
that you didn't understand why my suggestion would work, so decided
not to try it. I'm not going to help you further until you try the
advice I already gave.
As I said, the first filename is an argument to the -f flag.
Is there some reason you're not doing the following?
#variable {bgmPlay} {cmus-remote -l -c -f $backgroundMusicTrack $backgroundMusicTrack};
That will _not_ add the track twice, it'll play it immediately (the
-f <filename> part) and add it to the library (the second
<filename>) for repeats.
--
Jason
--
Powered by Arch Linux! I am registered Linux user number 508465: https://linuxcounter.net/user/508465.html
My blog, Thoughts of a Dragon: http://www.stormdragon.tk/
get my public PGP key: gpg --keyserver wwwkeys.pgp.net --recv-key 43DDC193
Twitter and Facebook are so ... yesteryear. Get your 2MB Social account TODAY! http://2mb.social/main/register
How to load Windows on your machine in 2 minutes or less:

"War! The very first war of our World! When the treacherous Witch was killed. Three times burned The three times born By searing flames Was Gullveig torn."
Amon Amarth - War of the Gods
Jason Woofenden
2015-09-25 22:06:55 UTC
Permalink
Oh! Sorry, my mistake.

Things to try now:

1. run cmus-remote from the terminal, and see what effect it has
on the running cmus (by looking at it's interface). check
whether it's having the expected effect on the library,
playlist, etc.

If it works perfectly from the terminal, then you know the
problem is in your game scripting.

2. If the cmus-remote call doesn't do what you expect, try doing
multiple calls to cmus-remote with fewer args, example:

cmus-remote -l -c
cmus-remote -l foo.mp3
cmus-remote -f foo.mp3

This should make it easier to figure out what's going on. If
you figure out a sequence of commands that works, let us know,
and maybe we can find a single command that does that, or find
a bug.

3. Check the cmus play mode... in the bottom right corner of cmus,
I see:

all from library | CRS

If it says "playlist" instead of "all from library" then it's
not going to make much difference what you ``cmus-remote -l``

If it still seems like there's a bug, please report to us:

1. The full commandline of cmus-remote that you use in the
terminal

2. Exactly what effect that has on the running cmus

3. How that differs from the behavior you expect
--
Jason

------------------------------------------------------------------------------
Storm Dragon
2015-09-25 22:54:57 UTC
Permalink
Howdy,
I got it working. Turns out because of the variables being passed at 2 different places, they were passing 2 different values. I should have figured that out sooner. So, fixed it with a simple if statement that passes the track twice if bgmPlaer is cmus, and once if it isn't.
Thanks for all the help :)
Storm
Post by Jason Woofenden
Oh! Sorry, my mistake.
1. run cmus-remote from the terminal, and see what effect it has
on the running cmus (by looking at it's interface). check
whether it's having the expected effect on the library,
playlist, etc.
If it works perfectly from the terminal, then you know the
problem is in your game scripting.
2. If the cmus-remote call doesn't do what you expect, try doing
cmus-remote -l -c
cmus-remote -l foo.mp3
cmus-remote -f foo.mp3
This should make it easier to figure out what's going on. If
you figure out a sequence of commands that works, let us know,
and maybe we can find a single command that does that, or find
a bug.
3. Check the cmus play mode... in the bottom right corner of cmus,
all from library | CRS
If it says "playlist" instead of "all from library" then it's
not going to make much difference what you ``cmus-remote -l``
1. The full commandline of cmus-remote that you use in the
terminal
2. Exactly what effect that has on the running cmus
3. How that differs from the behavior you expect
--
Jason
------------------------------------------------------------------------------
--
Powered by Arch Linux! I am registered Linux user number 508465: https://linuxcounter.net/user/508465.html
My blog, Thoughts of a Dragon: http://www.stormdragon.tk/
get my public PGP key: gpg --keyserver wwwkeys.pgp.net --recv-key 43DDC193
Twitter and Facebook are so ... yesteryear. Get your 2MB Social account TODAY! http://2mb.social/main/register
Follow me on GNU Social: https://social.stormdragon.tk/storm
"with a trunk big enough to fit three bodies in"
Calabrese - Crizila
Loading...