Question

I made a song player program using XNA 4.0 and I was wondering if there is a way to allow the user to play/load their own songs. I can play songs from a list that I make but I want the user to be able to play their own songs.

Was it helpful?

Solution

Have the user select a file. The song class can be instantiated using the file name:

Song usersSong= Song.FromUri(@"file:///" + openFileDialogue.FileName);

If you want them to have options for more than one song, you will have to manage the playlist yourself. Try getting them to identify a folder, getting all of the file names from that folder, and loading those file names into a list. You can then iterate through the list every time the xna mediaplayer raises the event that a song has finished playing.

With some elbow grease and creativity you can come up with some interesting ways of using a users music.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top