tags:

views:

602

answers:

4

Hi i received a request to create a Music Player with specific features ,sincerely i did not develop a Music Player in past time(just 7 months i began to develop programs Smile ). I try to explain correctly these features requested right now. This Music Player will Play music in modality "Random" (first request) downloading songs from a folder and one more request is to change "Genre" of music each 4 hours for example:

  • from 8am to 12am :it plays "Romantic" songs;
  • from 12am to 4pm :it plays "Latin" songs;
  • from 4pm to 8pm : it plays "Rock" songs;
  • from 8pm to midnight : it plays "Dance" music;

My purpose is to create different song's folder for each Genre and give respective TitleName(Romantic,Latin,Rock,etc..etc..) and when start the music player will automatic download the song's folder following the time slot...i hope to be clear. So i ask you some advice about the code how organize these features because i don't know how change the Genre Music for hours and put the music player in modality Random . I hope don't give you bother. Thanks in advantage.

Nice Regards

+1  A: 

Here's an approach.

Read all the ID3 tags for the MP3 files enqued in the playlist or folder using C# ID3 Library or any other ID3 tag reader for MP3 files. Probe the playlist, read ID3 tags, create a repo. Set the timer & pick a genre from your already read repo

AB Kolan
+1  A: 

You say that you are downloading songs from a folder, which leads me to believe that there is a server that is shuttling information to the media player.

I'd put the logic for this onto the server side. Just use whatever regular media player is out there.

Then, on the server side, generate a feed of some sort which feeds the URLs of the songs to download depending on the time of day on the server (adjusted by an offset if the client supplies one).

Then, your program would read the feed and get the urls of the songs to play, and just feed the playlist to the media player (or download the songs and feed them to the media player) based on what the server tells you.

casperOne
+1 Love the idea of generating a url feed with songs.
AB Kolan
+1  A: 

One Notion that would appear useful in your app is the concept of Song sources. A song source would essentially be an enumerable item that provides access to songs. This could firstly be an interface.

That way you have the abstract concept of a piece of code providing lists of songs. The actual player would access any implementation of ISongSource to get the next song to play, and play it. The playing bit, I am afraid I can't help you there. If all else fails you could create m3u files (mp3 playlists) from your song sources and start e.g. Winamp via Process.Start, passing the newly created playlist. In fact, this sounds like a neat version 1.

If you want to code everything you may need a piece of code to read ID3 tags from an mp3 file (If you are playing mp3 files). You should see this as independent functionality and chances are that there is already something available. The ID3 tagging is not very complicated, if I remember well there are defined byte offsets at the head of the mp3 file.

Based on this you should be able to implement song sources that consider ID3 tags in order to decide what song should be part of the source.

Finally there is the UI. That is a whole world on its own, especially if you would have a skinnable thing. But with a decent WPF book and some proof of concepts you should be on your way to get something done.

Happy coding!

flq
+1  A: 

Does it have to be a brand new media player? Depending on your requirements, you might consider wrapping Windows Media Player to do this. Here's a good starting point:

(Windows Media Player) Object Model Reference for Visual Basic .NET and C#

I've used the Windows Media Player SDK to do something similar to this. It's not the most straightforward API, but it's just one DLL, and it's relatively easy to send commands to it to get WMP to do stuff. Here's a link to the various SDK versions (which include the wmppia.dll you'll need):

Windows Media Downloads

Kyralessa