Skip to main content

Microsoft Silverlight

Answered Question Get Media Attributes From ASX filesRSS Feed

(0)

computerpro2
computer...

Member

Member

1 points

8 Posts

Get Media Attributes From ASX files

Hi,

 I am wondering how one would go about populating a listbox with the title of the video. Or perhaps someone could recommend an alternative to using an ASX playlist as a source?

 I am currently working with a dynamically generated asx playlist, which is created by reading a directory on my server (which is dreamhost) using php.

The asx file (while it has a .php extenstion) output contains:

 

<ASX version ="3.0">
<TITLE>ASX TEST</TITLE>
<ENTRY>
<TITLE>Holy Diver</TITLE>
<AUTHOR>Computerpro23</AUTHOR>
<REF HREF="http://computerpro23.dreamhosters.com/silverlight/videoplayer/uploads/Holy Diver.wmv"/>
</ENTRY><ENTRY>
<TITLE>My Curse</TITLE>
<AUTHOR>Computerpro23</AUTHOR>
<REF HREF="http://computerpro23.dreamhosters.com/silverlight/videoplayer/uploads/My Curse.wmv"/>
</ENTRY></ASX>
  

Even thought it still retains a php extension, it will play in an expression encoder template (you can view it here http://computerpro23.dreamhosters.com/silverlight/videoplayer/)

as an example say I would like to do is populate the list box of this mediaplayer (or a mediaplayer i create) with the TITLE information from each ENTRY in the asx file, how would i do that? Can someone give me some examples?

I am reletively new to SL, and .NET programming, I code all my applications in C#.

Another quick question, what are the supported playlist types for Silverlight 2?  if the above cannot be done can someone recommend a way to do this?

--William Johnson

bryant
bryant

Star

Star

9447 points

1,558 Posts

Silverlight MVP
Answered Question

Re: Get Media Attributes From ASX files

You could do this using something like the following code:

 

WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://computerpro23.dreamhosters.com/silverlight/videoplayer/"));


void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
  XElement xml = XElement.Parse(e.Result);
  var titles = (from t in xml.Descendants("ENTRY")
     select t.Descendants("TITLE").First().Value).ToList();
 }
 You'll need to add a reference to System.Xml.Linq in order to make this work. You'll probably also want to grab the URL for each title as well I imagine so that you can navigate to the right media file. To do this change what is selected in the Linq query.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

computerpro2
computer...

Member

Member

1 points

8 Posts

Re: Get Media Attributes From ASX files

Hi Bryant,

Thanks for your answer, If you wouldnt mind, can you show me how i would wire it all up in XAML? Here is the code for my php page that generates the ASX code. 

http://computerpro23.dreamhosters.com/silverlight/playlistgenerator.txt

 

--William Johnson

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

23562 points

2,304 Posts

Microsoft

Re: Get Media Attributes From ASX files

 Hi William,

Code posted by bryant shows us how to use WebClient to download a file and then use Linq to XML to filter the elements. In your condition, you'd better to do the code migration work by yourself.  For the details, please take a look at these video tutorials.

Best regards,

Jonathan

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities