次の方法で共有


Query.addCondition method

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The addCondition method adds a condition to the Query object using AND logic.

Syntax

Query.addCondition(
  attribute,
  operator,
  value
)

Parameters

attribute [in]

String containing the attribute name.

operator [in]

String containing the operator. See Remarks for supported values.

value [in]

String containing the attribute value.

Return value

This method does not return a value.

Remarks

Compound queries using Query are not case sensitive.

A list of values for the attribute parameter can be found in the Alphabetical Attribute Reference section.

Conditions contained in a Query object are organized into condition groups. Multiple conditions within a condition group are always concatenated using AND logic. Condition groups are always concatenated to each other using OR logic. To start a new condition group, call Query.beginNextGroup.

The following table lists the supported values for operator.

Operator Applies to
BeginsWith Strings
Contains Strings
Equals All types
GreaterThan Numbers, Dates
GreaterThanOrEquals Numbers, Dates
LessThan Numbers, Dates
LessThanOrEquals Numbers, Dates
NotBeginsWith Strings
NotContains Strings
NotEquals All types

Examples

The following JScript example uses Query.addCondition and Query.beginNextGroup to perform an example query.

// Perform an example query for media for which:
// The genre contains "jazz"
// and the title begins with "a"
// OR the genre contains "jazz"
// and the author begins with "b".

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

// Add the first condition group.
Query.addCondition("WM/Genre", "Contains", "jazz");
Query.addCondition("Title", "BeginsWith", "a");

// Begin the new condition group ("or").
Query.beginNextGroup();

// Add the second condition group.
Query.addCondition("WM/Genre", "Contains", "jazz");
Query.addCondition("Author", "BeginsWith", "b");

// Perform the query on "audio" media.
var Playlist = Player.mediaCollection.getPlaylistByQuery(
    Query,      // query
    "audio",    // mediaType
    "",         // sortAttribute
    false);     // sortAscending

Requirements

Requirement Value
Version
Windows Media Player 11.
DLL
Wmp.dll

See also

MediaCollection.createQuery

MediaCollection.getPlaylistByQuery

MediaCollection.getStringCollectionByQuery

Query Object

Query.beginNextGroup