tags:

views:

774

answers:

3

I'm trying to display a video feed which is provided as a server side playlist (ASX) by another party. The playlist contains some unsupported features, such as repeat:

<ASX VERSION="3.0">
  <REPEAT COUNT="4">
    <EntryRef href="http://some-ad-network.com/ad.asx" />
    <Entry>
      <Ref href="http://video-host/content-primary-source"&gt;&lt;/Ref&gt;
    </Entry>
    <Entry>
      <Ref href="http://video-host/content-secondary-source"&gt;&lt;/Ref&gt;
    </Entry>
  </REPEAT>
</ASX>

Silverlight 2.0 doesn't support the REPEAT element and throws an exception:

REPEAT Element: This is not supported and will raise a MediaError with AG _ E _ ASX _ UNSUPPORTED _ ELEMENT.

Is there a workaround? Can I pull the ASX file down via HttpWebRequest, parse it, and request the streams individually? Do you know of a library or some sample code somewhere which handles ASX file parsing?

A: 

The Attributes gets the collection of MediaAttribute objects that corresponds to the current entry in the ASX file that Source is set to. here is a javascript example:

http://msdn.microsoft.com/en-us/library/bb412367.aspx

Peter Bromberg
I can't load the ASX file in Silverlight - it throws an exception. How can I get at the Attributes if I can't load it?
Jon Galloway
A: 

I ended up having to parse the ASX file myself and manually load the elements. Peter's suggestion is helpful if the ASX file will load, but the Silverlight ASX parser throws exceptions when it encounters most unsupported elements so you never get the chance to load from the Attributes property.

Jon Galloway
A: 

I also made a custom asx parser because of bad asx handling in the MediaElement. It corrects several bugs, see http://blog.revolunet.com/index.php/general/wpf-mediaelement-asx-workaround