Page view counter
Get Media Attributes From ASX files Subscribe to this thread
Last post 12-02-2008 2:51 AM by Jonathan Shen – MSFT. 3 replies.
Sort Posts:
11-26-2008 12:55 PM
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

computerpro2

Loading...
Joined on 05-09-2008
Posts 5
11-26-2008 3:14 PM
Marked as Answer
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.

bryant

Loading...
Joined on 10-23-2002
Simi Valley, CA
Posts 1,153
11-26-2008 4:42 PM
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

computerpro2

Loading...
Joined on 05-09-2008
Posts 5
12-02-2008 2:51 AM
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.

Jonathan Shen – MSFT

Loading...
Joined on 06-18-2007
Posts 1,522
Microsoft Communities