Windows Media Player 11 SDK IWMPMedia.isReadOnlyItem (VB and C#)
Previous | Next |
IWMPMedia.isReadOnlyItem (VB and C#)
The isReadOnlyItem method returns a value indicating whether the attributes of the specified media item can be edited.
[Visual Basic] Function isReadOnlyItem( bstrItemName As String ) As Boolean [C#] bool isReadOnlyItem ( string bstrItemName );
Parameters
bstrItemName
A System.String that is the name of the media item.
Return Value
A System.Boolean value that indicates whether the attributes are read-only.
Remarks
If an attribute is read-only, then it cannot be set with the setItemInfo method. Note that this method may return different values for a particular attribute when used with different versions of Windows Media Player.
Before calling this method, you must have read access to the library. For more information, see Library Access.
Example Code
The following example uses isReadOnlyItem to fill a multi-line text box with information about the current media item. The code displays each attribute of the current media item, along with text indicating whether the attribute is read-only or read/write. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
[Visual Basic]
' Store a WMPLib.IWMPMedia3 interface to the current media item. Dim cm As WMPLib.IWMPMedia3 = player.currentMedia ' Get the number of attributes in the current media item. Dim attCount As Integer = player.currentMedia.attributeCount ' Create an array to store the list of attribute information. Dim atInfo(attCount) As String ' Create a variable to hold each attribute name. Dim atName As String ' Loop through the attribute list. For i As Integer = 0 To (cm.attributeCount - 1) ' Get the attribute name. atName = cm.getAttributeName(i) ' Test whether the attribute is read-only. If (cm.isReadOnlyItem(atName)) Then atInfo(i) = (atName + " is Read-Only") Else atInfo(i) = (atName + " is Read/Write") End If Next i ' Display the attribute information in the text box. rwText.Lines = atInfo
FakePre-50c20b062c704790bdbbb574488fc35f-99b448a369eb47b58f9784b1740be4b9
// Store a WMPLib.IWMPMedia3 interface to the current media item. WMPLib.IWMPMedia3 cm = (WMPLib.IWMPMedia3)player.currentMedia; // Get the number of attributes in the current media item. int attCount = player.currentMedia.attributeCount; // Create an array to store the list of attribute information. string[] atInfo = new string[attCount]; // Create a variable to hold each attribute name. string atName; // Loop through the attribute list. for (int i = 0; i < cm.attributeCount; i++) { // Get the attribute name. atName = cm.getAttributeName(i); // Test whether the attribute is read-only. string test = ((cm.isReadOnlyItem(atName)) ? "Read-Only" : "Read/Write"); // Store the attribute information in the array. atInfo[i] = (atName + " is " + test); } // Display the attribute information in the text box. rwText.Lines = atInfo;
Requirements
Version: Windows Media Player 9 Series or later
Namespace: WMPLib
Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)
See Also
Previous | Next |