Re: [Banshee-List] Re trieve Music Collection from Extension



On Fri, Mar 5, 2010 at 12:18 PM, nstamato <nstamato gmail com> wrote:
>
> Hello,
>
> I'm writing an extension for Banshee and I need to be able to search the
> music library in a meaningful way. That is to say, I would like to be able
> to query Banshee to return all the tracks of a certain artist, or a certain
> album etc. I've been looking around in the source code and the only thing I
> could find was to use the CollectionIndexerService. That way I can create an
> index which I can then access with the GetModelResultsCount(int modelIndex),
> GetResult(int modelIndex, int itemIndex) methods and go through all the
> items of the collection checking for songs of a certain artist. That seems
> too inefficient however. Doesn't bansee have an internal way of searching
> the music collection and returning the appropriate information?
>
> Any help would be appreciated.

Probably the easiest/most powerful way is to create a temporary,
hidden smart playlist.  This is what the sync feature does to
calculate what songs to add and remove from a device:
http://git.gnome.org/browse/banshee/tree/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs#n149

As you see there, you can use the AddCondition or ConditionTree
members to specify your query.  Then you can iterate the smart
playlist with:

var model = source.TrackModel;
for (int i = 0; i < model.Count; i++) { var track_i = model[i]; }

Or you can call any of the methods on the source or model.

Gabriel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]