Share via


Windows Media Player 11 SDK About the Query Object 

Windows Media Player SDK banner art

Previous Next

About the Query Object

The Query object represents a compound query. You create a new, empty Query object by calling mediaCollection.createQuery. After you have created a Query object, you can call addCondition to add a condition to the compound query. Each subsequent call to addCondition appends a new condition to the existing query using AND logic.

For example, suppose you want to create a query that represents all digital media where WM/Genre equals "Jazz" and Author contains "Jim". You could create a compound query to represent these conditions by using the following JScript code:

// Create the query object.
var Query = player.mediaCollection.createQuery();

// Add the conditions.
Query.addCondition("WM/Genre", "Equals", "Jazz");
Query.addCondition("Author", "Contains", "Jim");

To add a condition to a compound query using OR logic, you must call Query.beginNextGroup. This method signals that the previous condition group is completed and that the next call to addCondition represents the start of a new condition group.

For example, to create a query that represents all digital media where WM/Genre equals "Jazz" and Author contains "Jim" or Author contains "Dave", you could use the following example code:

// Create the query object.
var Query = player.mediaCollection.createQuery();

// Add the conditions.
Query.addCondition("WM/Genre", "Equals", "Jazz");
Query.addCondition("Author", "Contains", "Jim");

// Start the next condition group. This group will be
// combined with the previous group using a logical OR operation.
Query.beginNextGroup();

// Add the conditions.
Query.addCondition("WM/Genre", "Equals", "Jazz");
Query.addCondition("Author", "Contains", "Dave");

To execute your compound query, call MediaCollection.getPlaylistByQuery.

See Also

Previous Next