Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
IWMPQuery.addCondition (VB and C#)
The addCondition method adds a condition to the compound query using AND logic.
[Visual Basic] Sub addCondition( bstrAttribute As String, bstrOperator As String, bstrValue As String ) [C#] void addCondition ( string bstrAttribute, string bstrOperator, string bstrValue );
Parameters
bstrAttribute
A System.String that is the name of the attribute to be added to the query.
bstrOperator
A System.String that is the operator. See Remarks for supported values.
bstrValue
A System.String that is the attribute value.
Return Value
This method does not return a value.
Remarks
Conditions contained in a compound query are organized into condition groups. Multiple conditions within a condition group are always concatenated by using AND logic. Condition groups are always concatenated to each other by using OR logic. To start a new condition group, call IWMPQuery.beginNextGroup.
Compound queries using IWMPQuery are not case sensitive.
A list of values for the bstrAttribute parameter can be found in Alphabetical Attribute Reference.
The following table lists the supported values for bstrOperator.
| String | 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 |
Example Code
The following example creates a query, adds two conditions to it, and uses that query to extract the results of the query as a string collection. The results are then displayed in a list box. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
[Visual Basic]
' Get a new Query interface.
Dim mc As WMPLib.IWMPMediaCollection2 = player.mediaCollection
Dim q As WMPLib.IWMPQuery = mc.createQuery()
' Add two conditions to the Query.
q.addCondition("WM/Composer", "Equals", "Antonio Vivaldi")
q.addCondition("Title", "Contains", "Trio")
' Query the media collection and get a string collection containing the result.
' In this case, the string collection will contain the titles of all audio items that
' match the query.
Dim result As WMPLib.IWMPStringCollection2 = mc.getStringCollectionByQuery("Title", q, "audio", "", False)
' Display the results by adding them to a list box.
For i As Integer = 0 To (result.count - 1)
queryResults.Items.Add(result.Item(i))
Next i
FakePre-11889c746c4f4c2fadcbcd9a7c2afa46-e0d9505bf8334083bdbd5e768c3fb8f7
// Get a new Query interface.
WMPLib.IWMPMediaCollection2 mc = (WMPLib.IWMPMediaCollection2)player.mediaCollection;
WMPLib.IWMPQuery q = mc.createQuery();
// Add two conditions to the Query.
q.addCondition("WM/Composer", "Equals", "Antonio Vivaldi");
q.addCondition("Title", "Contains", "Trio");
// Query the media collection and get a string collection containing the result.
// In this case, the string collection will contain the titles of all audio items that
// match the query.
WMPLib.IWMPStringCollection2 result = (WMPLib.IWMPStringCollection2)mc.getStringCollectionByQuery("Title", q, "audio", "", false);
// Display the results by adding them to a list box.
for (int i = 0; i < result.count; i++)
{
queryResults.Items.Add(result.Item(i));
}
Requirements
Version: Windows Media Player 11.
Namespace: WMPLib
Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)
See Also
- Alphabetical Attribute Reference
- IWMPMediaCollection2.createQuery (VB and C#)
- IWMPMediaCollection2.getPlaylistByQuery (VB and C#)
- IWMPMediaCollection2.getStringCollectionByQuery (VB and C#)
- IWMPQuery Interface
| Previous | Next |