Is it possible to play all the .mp3’s within a folder in windows media player?
I am using Python 3.2, and so far I have code that returns the absolute location of a random album in my music folder.
I would like to take that string and somehow open WMP and play the music within that folder
Any suggestions?
For reference, here is my code:
import random
import os
path = ["Q:\\#User\\Music\\", "Q:\\#user\\What CDs\\"]
print("You shall play " + random.sample(list(filter(lambda f: len([i for i in f if i in "."]) == 0, sum(map(lambda d: list(map(lambda e: d + "\\" + e,os.listdir(d))),list(filter(lambda c: len([i for i in c if i in "."]) == 0, sum(map(lambda a: list(map(lambda b: a + b ,os.listdir(a))), path), [])))), []) )), 1)[0])
input()
And yes, ideally that wouldn’t all be in one line. I was learning how to use map and lambda and thought I’d challenge myself.
I’d now like to take this one step further, and play the random album.
Thanks!
Hmmmm, interesting idea.
I would probably create a .m3u file on the fly and then pass it to WMP as a command line argument (which, according to WMP Command Line is certainly doable).
A .m3u file is simply a text file. Here is an example .m3u for the Tool album Undertow:
Good luck!
PS – You can invoke the command line argument by importing the
osmodule and usingos.system("YOUR DOS COMMAND")Oh, and the format used in an m3u file:
If it wasn’t clear.