GetItemByName Method
Gets the MediaAttribute for the collection with the Name equal to the specified string.
XAML |
Cannot use methods in XAML.
|
Scripting |
retval = object.GetItemByName(name)
|
Parameters
name | string The name of the MediaAttribute to get from the collection. |
Return Value
The MediaAttribute with the Name property equal to the specified string if found; otherwise, null.
Remarks
GetItemByName is a convenience method that retrieves media attributes without requiring you to iterate the entire collection.
Examples
The following JavaScript example shows how to retrieve a MediaAttribute by name from the Attributes property of a MediaElement that has a Source property set to an ASX playlist file. The Name and Value properties of the MediaAttribute is then displayed.
JavaScript |
---|
function onMediaOpened(sender, args) { // Variable to hold the MediaAttribute. var attribute; // Get the MediaAttribute named Title try { var attributesCollection = sender.Attributes; attribute = attributesCollection.getItemByName("Title"); } catch(errorObj) { alert(errorObj.message); } // Display the Value of the MediaAttribute if(attribute != null) { alert("The title of the track is: " + attribute.value); } } |
Applies To
See Also
Referencing and Modifying Silverlight Objects
MediaElement
Attributes