Export (0) Print
Expand All

MediaAttribute Object

Represents an attribute from an entry in an ASX file.

XAML
See Remarks.
Scripting
To create an object using scripting, see CreateFromXAML.

Properties

Name, Value

Methods

Equals, FindName, GetHost, GetValue, SetValue

Remarks

MediaAttribute technically does have a XAML usage and can be instantiated as a XAML object element. However, this usage does not have have any practical application. The useful collection of MediaAttribute objects is contained within the metadata of each given source that is loaded by a MediaElement. You can get this collection as the Attributes property through scripting, and this collection is not valid until the MediaOpened event is raised. Specifying a MediaAttribute in XAML ahead of time as part of a MediaElement will only result in that entire Attributes value being erased and replaced as soon as a media source is loaded by the MediaElement.

Examples

The following JavaScript example shows how to retrieve the Attributes property of a MediaElement that has a Source property set to an ASX playlist file. The retrieved MediaAttributeCollection is iterated through and the Name and Value properties of each MediaAttribute is 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);
    }
}

See Also

Media Overview
MediaAttributeCollection
MediaElement
Attributes

Community Additions

Show:
© 2014 Microsoft