Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Get Media Attributes From ASX files
3 replies. Latest Post by Jonathan Shen – MSFT on December 2, 2008.
(0)
computer...
Member
1 points
8 Posts
11-26-2008 12:55 PM |
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?
bryant
Star
9447 points
1,558 Posts
11-26-2008 3:14 PM |
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();
}
11-26-2008 4:42 PM |
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
Jonathan...
All-Star
23562 points
2,304 Posts
12-02-2008 2:51 AM |
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