Hi Terry,

> > Change it back to that and take them to be directory names instead,
> > and `daisy/*.mp3' is what you pass to mpg321 using your existing
> > `sorted(...listdir)' functional-programming thingy.
...
> > mpg321 has a -l option to loop N times.  If N is 0 then forever.  So
> > your callback starts mpg321 with -l and gives it the sorted list of
> > all the MP3s in the current playlist-directory entry, e.g.
> > `valkyries/*.mp3'.  Then it forgets all about it until it's time to
> > SIGTERM it.
>
> even if I explicitly change directory to the one containing the files

Don't do that.

> mp3_player = subprocess.Popen(['mpg321', '-q', '-m', '-a', 'hw:0,0', '*.mp3'])

But that's not "using your existing... functional-programming thingy"
mentioned above.

    mp3_files = sorted(os.path.join(mp3_subdir, x) for x in
        filter(lambda f: f.lower().endswith(".mp3"), os.listdir(mp3_subdir)))

There's also glob.glob() that would probably make the above simpler.
https://docs.python.org/2/library/glob.html

    mp3_files = sorted(glob.glob(mp3_subdir + '/*.[Mm][Pp]3'))

mpg321 sees the literal string `*.mp3' and tries to open it.  If it
exists, it would play it.

A raw `*.mp3' in the source don't mean those filenames to Python as it
doesn't glob strings like a shell.  That's why you're doing listdir(),
etc.

I think part of the problem here is you're trying to write a program to
meet your needs in Python, not trying to learn Python so you can then
write a program to meet your needs.  :-)

Cheers, Ralph.

-- 
Next meeting:  Bournemouth, Tuesday, 2017-03-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue     / TO THE LIST OR THE AUTHOR

Reply via email to