Search code examples
c#xnawindows-media-player

XNA MediaLibrary not being populated with media files


I am trying to get started with XNA and C#. Unfortunately, however, I am having a huge problem making any progress with a small task: accessing and playing music files on my computer.

Currently, I am using XNA with a Windows Forms Application, and in the my main form's Load event I implemented the following:

private void frmMain_Load(object sender, EventArgs e)
{
    using (MediaLibrary library = new MediaLibrary())
    {
        SongCollection songs = library.Songs;
        MessageBox.Show("Songs Count: " + songs.Count.ToString());
    } 
}

The messagebox shows: Songs Count: 0 no matter what. My understanding is that on windows, my media player has to find the media files in the system before XNA can find them, so I checked with my media player, and all the music files, playlists, and video files were there. Any suggestions?


Solution

  • XNA simply doesn't work like that: It expects all content to be directly included in the XNA Content Folder (and accessed via Content.Load<..>(..);)*. Might I recommend you read some related XNA Tutorials on the subject before you continue asking questions?

    .

    *There are ways around this, but they are much more advanced, and I don't get the impression from your post that you're ready for things like that.