XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

audio search/filter

Last post 06/11/2009 1:37 PM by doomHmmr. 4 replies.
  • 05/11/2009 4:51 AM

    audio search/filter

    Hi Guys,

    Long story short - I want to filter down the songs by genres, then albums. The way it would work is the user gets a list of all genres. They select one. Then they get a list of all albums within the genre. They select one. Then they would get a list of songs for that specific album.

    I know that I can loop through every single song to find ones that match my criteria and go from there. That is a very ugly solution though and very inefficient. Is there a way to filter songs by being able to specify what fields I want to filter on and what their values have to be? I thought I saw a piece of code somewhere that lets one do it, but I can't seem find it anymore.

    A second part of the problem will be that I want to add a "save" ability to bookmark where you left off (the way podcasts work). Do songs have some sort of a identifier that I could store, or would I have to store a genre, album, artist & name (and then search by all those fields)? I am hesitant to use the song #, because once even a single song is removed, the entire index can change..

    Thanks a lot
  • 05/11/2009 6:08 AM In reply to

    Re: audio search/filter

    What's wrong with MediaLibrary.Genres, which gives you a GenreCollection, which has an Albums property which gives you Albums?
    What is it you want to do that those won't do for you?

    The PlayPosition can be had from MediaPlayer, but can't be restored in any way I know.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 05/11/2009 11:08 PM In reply to

    Re: audio search/filter

    Can I use the genre collection to filter down the music to display a select album only? Can I then play that group of songs as a media collection/play list? Or how would I create a play-list based on that?

    What I want is to allow the user to do the following:
        * display a list of genres -> user selects one
        * display a list of albums in that genre -> user selects one
        * display a list of music in that album -> user selects to play all, or one in the list. As the song is done, we move on to the next one. Previous and Next should be supported.

    Eventually I will be adding bookmarking and resume -> I want to create a better way to play audiobooks, since I am not happy about any ways the Zune supports it right now..

    Would the genre collection support that? Thanks a lot!!
  • 06/11/2009 6:05 AM In reply to

    Re: audio search/filter

    Step one and two, and half of three, is built into the GenreCollection and the Albums collection in the Genre.
    Once you have an Album, it has Songs, which you can play any way you want. As a straightforward way of doing it, simply build a List<Song>, and check for the MediaPlayer ending the current song; when it does, simply play the next Song in your list. Also read this note in the documentation of SongCollection.
    Isn't MSDN great? :-)
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 06/11/2009 1:37 PM In reply to

    Re: audio search/filter

    thank you! That will make my life so much easier.

    One problem - I am not sure if I am being slow or blind this morning, but nowhere in those articles do they actually tell me how to get the specific genre or album songs.. (I found those pages before, but all they do is say that it's possible, and to use "Get", but not how to do the filtration). My question is how -> I didn't see a function that says "GetByAlbum" or something similar.

    The code I saw (but can't seem to be able to find) was something like Library.Get<albums>("AlbumName") => in other words, you need to know the terms to put into brackets.. I will look through MSDN later some more (at work now), but if you run into any code, I'd appreciate it.. :)

    Thanks a lot!
Page 1 of 1 (5 items) Previous Next