It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
avatar
dtgreene: (mpv will fail if xorg isn't running unless a command-line argument is used to disable video,
this seems wrong.
at least it works just fine here playing a mp3 track.
mpv will only try to initialize video output if the media file contains a video track.
And since by default it will choose X for video output that will fail if Xorg isn't running.
But telling to ignore the video (or use a console based render) will still work.

if the extra commandline argument annoys you, you can set up the config file to always ignore the video.
just write "video=no" to ~/.config/mpv/mpv.conf

(might want to double check the exact config path)
avatar
dtgreene: What's the command to play just one file and then immediately exit?

(cvlc doesn't do that; it continues running when the track is done and I have to Ctrl-C it. nvlc is interesting, and something I may use, but not actually what the topic is asking for (in particular, it's not suitable for something like a cron job).)
In fact it does.

I sometimes use cvlc --play-and-exit file which does exactly what you need, play and close.
avatar
dtgreene: What's the command to play just one file and then immediately exit?

(cvlc doesn't do that; it continues running when the track is done and I have to Ctrl-C it. nvlc is interesting, and something I may use, but not actually what the topic is asking for (in particular, it's not suitable for something like a cron job).)
avatar
sanscript: In fact it does.

I sometimes use cvlc --play-and-exit file which does exactly what you need, play and close.
It's still a pain to enter that every single time I want to play just one file and then exit.
avatar
Pseudoman: I think you need to specify a special item in the playlist that instructs vlc to exit, like:
cvlc item1.mp3 item2.mp3 vlc://quit

reference: https://linux.die.net/man/1/vlc
avatar
dtgreene: That works, but it's annoying to have to do that every time, so it doesn't solve my issue.
that's where the power of bash scripting comes in! (or whatever shell you're using)

example:

./playit.sh file.flac

``` playit.sh
#!/bin/bash
cvlc $1 vlc://exit
```

would be the same as having run: cvlc file.flac vlc://exit

you would need to "chmod +x playit.sh" to make it executable

reference: https://www.linux.com/training-tutorials/writing-simple-bash-script/


avatar
sanscript: In fact it does.

I sometimes use cvlc --play-and-exit file which does exactly what you need, play and close.
avatar
dtgreene: It's still a pain to enter that every single time I want to play just one file and then exit.
depending on you level of familiarity with linux, you may find a resource like https://ryanstutorials.net/ to be helpful
Post edited March 13, 2021 by Pseudoman
avatar
dtgreene: Also, does anyone have any similar recommendations for Android? (Here I require that it allows browsing by folder, can play just one track and then stop (instead of going onto the next), is open source, is available somewhere other than Google Play, and I would prefer for it to *not* have network access.)
in regards to my prior post on VLC for this... try NetGuard - its still in development, but its free, its on the playstore and you can block pretty much anything from accessing the net (no root access required). i gave it a go today and it seems to be working quite nicely (tested a few things with it).

Edit: only issue is it works by making a fake VPN, so any real VPN you might launch will turn it off.
Post edited March 13, 2021 by Sachys
avatar
dtgreene: That works, but it's annoying to have to do that every time, so it doesn't solve my issue.
avatar
Pseudoman: that's where the power of bash scripting comes in! (or whatever shell you're using)

example:

./playit.sh file.flac

``` playit.sh
#!/bin/bash
cvlc $1 vlc://exit
```

would be the same as having run: cvlc file.flac vlc://exit

you would need to "chmod +x playit.sh" to make it executable

reference: https://www.linux.com/training-tutorials/writing-simple-bash-script/
Other issue is that it would only run from the directory the script is stored in, or else I'd need to enter a longer path rather than just the file name.

(Also, for whatever reason, it is *very* common for files from downloaded soundtracks to have spaces in their names, which is an issue if I want to, say, batch convert them.)

It would actually work better to use a batch alias in this case.
Have you taken a look at mpd (Music Player Daemon)?

a) If your aim is to use your Raspberry Pi plugged into a sound system to play music by SSH'ing to it, this fits perfectly your use case and further empowers you.

b) If you just want to check some sound files while working at a terminal, I think it can still work well but you may need to work out some things.

It works in two parts:
- the daemon that plays music (no surprise there) that needs to be running in the background. You can load it on boot and (I believe) takes up very few resources. The daemon manages and indexes a library of files that you can refer to by their file names or tags. For use case a) this is useful, as referring to files is much simpler. Still, you can provide it with new files that are not indexed (or to be indexed) for use case b).

- the second part is a client that is your form of communication with the daemon. You can find command-line clients like mpc (that comes with the daemon) that are very unobtrusive and really get out of the way in the command line, several clients that and an ncurses interface, and even clients for phones. The communication can go though the network or you can nuke that possibility and access the daemon locally only.
For case b) you just need to figure out how to supply / refer the file to the daemon and how to stop it mid play (since Ctrl-C won't make it stop playing).

I hope it helps.
|dev/zero
avatar
Pseudoman: that's where the power of bash scripting comes in! (or whatever shell you're using)

example:

./playit.sh file.flac

``` playit.sh
#!/bin/bash
cvlc $1 vlc://exit
```

would be the same as having run: cvlc file.flac vlc://exit

you would need to "chmod +x playit.sh" to make it executable

reference: https://www.linux.com/training-tutorials/writing-simple-bash-script/
avatar
dtgreene: Other issue is that it would only run from the directory the script is stored in, or else I'd need to enter a longer path rather than just the file name.

(Also, for whatever reason, it is *very* common for files from downloaded soundtracks to have spaces in their names, which is an issue if I want to, say, batch convert them.)

It would actually work better to use a batch alias in this case.
if you have admin access, you can move the script into one of your $PATH locations -- or add it to ~/bin/ and add that to your $PATH. then can be executed even outside of the stored directory

again, looking at bash scripting resources, and perhaps even a site like stackexchange can help with specific challenges like spaces in name. chances are someone else has already solved a similar issue before, just needs some research to find ;)
avatar
dtgreene: mpv will fail if xorg isn't running unless a command-line argument is used to disable video
Then something is wrong with your setup.
Running audio files with mpv outside of a X or Wayland session is part of my daily routine.
avatar
dtgreene: mpv will fail if xorg isn't running unless a command-line argument is used to disable video
avatar
vv221: Then something is wrong with your setup.
Running audio files with mpv outside of a X or Wayland session is part of my daily routine.
yup the problem is between the keyboard and the chair
avatar
sanscript: In fact it does.

I sometimes use cvlc --play-and-exit file which does exactly what you need, play and close.
avatar
dtgreene: It's still a pain to enter that every single time I want to play just one file and then exit.
Been a while since I dabbled much in Linux shell, but you can just make a ilink or something where the standard command includes some arguments. Like you normally would do with ls = ls -lia f.ex.:

cvlc = cvlc --play-and-exit.

Then all you need to enter is "cvlc file" and then it plays and closes. Just can't remember how right now...

Or, create a python script which basically does the same thing.

EDIT: Of course, alias:
alias cvlc='cvlc --play-and-exit'

Or, just echo it into bashrc/bash_aliases so it's there when you restart.

EDIT2:
Or, create a new command/script which is alised to a file:
alias c1=' --play-and-exit /home/user/Music/playlist.xspf'
Post edited March 14, 2021 by sanscript
avatar
Pseudoman: again, looking at bash scripting resources, and perhaps even a site like stackexchange can help with specific challenges like spaces in name. chances are someone else has already solved a similar issue before, just needs some research to find ;)
In the particular case I mentioned, I believe I just gave up and wrote a Python script instead.

(os.spawn and subprocess.run allow you to run a program supplying the arguments as separate function arguments instead of them being parsed as a string.)

Rust also has a built-in module that lets you do this sort of thing (though note that Rust takes more work to write, though the code is more likely to be correct once it's written).
avatar
dtgreene: Also, does anyone have any similar recommendations for Android?
I've been using foobar2000 for years, and I'm very happy with it. Not sure if you can get it outside the Play store though.