7
1
On occasion I get a little blue and need a little music to cheer me up, but clicking the start button and finding my media player takes sooooooo long. I want a faster way to play a song.
The challenge:
Write a program that:
Choose a song from my home directory (so you don’t mix-up program sound files with music) (this includes sub folders of the home directory).
This song should be a random choice from all the media in my home folder. This doesn't need to be a perfect random, but I don't want to hear the same song multiple times. (unless that's my only song ;)
To make it simple you should only look for files ending in
.mp3
.In the event that you find no music in my home dir, you should print
Sorry Joe, no Jams!
to stdout or closest equivalent (btw my name isn't Joe ;)The layout of my home folder will contain no infinite loops
You should use system to play the song instead of using built in media playing APIs in your language (i.e. I want the song to play in the default player for my system).
I should be able to place this file anywhere on my computer (e.g. my desktop or start folder)
Your answer should work on windows, multi-platform is a (un-scored) bonus
This is code golf so the shortest program in bytes wins!!
2What is your home dir? – Adám – 2015-10-13T13:41:59.953
It will differ from computer to computer, so you should use a builtin in your land to determine that. (e.g. in python
os.path.expanduser('~')
) – J Atkin – 2015-10-13T13:47:27.807Lol, I meant lang, not land – J Atkin – 2015-10-13T13:54:39.490
2waiting for an answer in CJam :) – WizardOfMenlo – 2015-10-13T14:26:59.953
May I post a theoretical answer? I haven't used Windows in years, but I think I know an answer. It won't be golfed because I don't know that I can actually test it. – Addison Crump – 2015-10-13T15:17:10.587
Go ahead, If I know how to use it I can try to test it for you. Otherwise some passer by might be nice and test it ;-) – J Atkin – 2015-10-13T15:18:31.880