Short-cut to integrate Web Playlists with an existing web application

If you read my post / walkthroughs you probably know about the extensibility interface shipped with CTP2. You can use that to integrate into existing business logic applications or web applications. However, in this post I am going to talk about a shortcut, you don't have to write a custom provider if you don't want to. Don't you love shortcuts? If you don't like dealing with new interfaces I am sure you would love that.

So what am I talking about? With CTP2, we also released httpd entries. This feature allows you to refer another web application as one of the entries. Let me explain that in more details.

Typically, a Web Playlists would look like this (let us call it Playlist1):

Playlist1.isx:
<?xml version="1.0" encoding="UTF-8"?>
<playlist name="Demo4" title="Demo Playlist 4" description="Demo of integration with Web Application">
        <entry location="C:\test\media\Videos\Ad.wmv" locationType="relativeURI" clientSkipFwd="true" clientSkipBack="true" clientSeek="true" />
        <entry location="C:\test\media\Videos\WatchMe.wmv" locationType="physicalPath" clientSkipFwd="true" clientSkipBack="true" clientSeek="true" />
</playlist>

Now consider a slightly different form of specifying the above playlist (let us call it Playlist2)

Playlist2.isx:
<?xml version="1.0" encoding="UTF-8"?>
<playlist name="Demo4" title="Demo Playlist 4" description="Demo of integration with Web Application">
        <entry location="httpd://{SERVER_NAME}:{SERVER_PORT}/pre.aspx" locationType="relativeURI" clientSkipFwd="true" clientSkipBack="true" clientSeek="true" />
        <entry location="C:\test\media\Videos\Movie Trailers\Elephant's Dream 720p 2M.wmv" locationType="physicalPath" clientSkipFwd="true" clientSkipBack="true" clientSeek="true" />
</playlist>
 

If you look closely, we have replaced the Ad.wmv with a httpd:// URL. This entry now points to an Asp.Net page pre.aspx. Now let us take a stab at writing the aspx page.

Pre.aspx:
<%@ Page ContentType="text/plain" Language="c#"  %>
Ad.wmv

Okay, I know what you are thinking, how could I have chosen such a complicated piece of aspx code as an example. The idea is not to teach you how to write aspx code but the concept is important. I am sure you can write much better aspx code than I can. (well you could even point this to php code or any other web application if you prefer that route)

What we have done here is following:

  1. Set the ContentType attribute for the page to "text/plain", and
  2. returned the Ad.wmv in the response

This makes Playlist1 and Playlist2 contain exactly same entries. What we did here that instead of hard coding Ad.wmv into the playlist retrieved it from an aspx page. You can have any logic you need inside the asp code but as long as you return a string path corresponding to the locationType (in the playlist above), you are set.

Also, if you notice in the URL requesting the web page we used {SERVER_NAME} and {SERVER_PORT}, these are server variables in the IIS pipeline, you can pass any server variables as a part of the URL request. The list of available server variables is available online here. Don't loose your heart if you think these are not enough, you can also pass any other information your application needs by setting custom variables in the IIS pipeline. All you need to do to achieve that is to write a simple IIS module to set a server variable in the IIS pipeline. The module will make use of the SetServerVariable() API available with IIS 7, details here.

Here is how the call flow for the above interaction looks like:

image 

Okay, I know I talked about this in the walkthrough as well, so nothing new so far.

Now that we know how to reference a web page, in the web page we could have the logic to retrieve the playlist entry based on a business logic, configuration stored in a database or just request the same from an existing application. Here is how the revised call flow will look like:

image

 

This is just another way to integrate with existing business logic applications, you can always chose to write a custom provider. Custom providers provide much more powerful way of integrating existing applications with web playlists. I consider httpd entries as a shortcut method to achieve this kind of integration.

5 Comments

  • Hi,
    I installed IIS media pack 1 in my IIS7
    I created a playlist1.isx

    Please, could you be so nice and show or send me a complete working aspx page to play it? The above example was too short for me, you know, old dog...

    Thanks in advance,
    Ricardo

  • Hi, again
    In my http://200.157.23.252/ a have a file "RSMplaylist1.isx".
    Please, I would like to know how to make a simple aspx page to play it.

    Another thing: my wmp11 can't open url above and play isx file. Do I need to configure something else (I already fixed the firewall)?
    Best regards,
    Ricardo

  • Hi Ricardo.

    I am sorry I missed this comment.

    Do you still need help? What would you like to do with the aspx page? If you create a page a.aspx and copy the below text in it and refer the playlist to that page, it would work


    Ad.wmv

    Regards
    Vishal

  • Hi Ricardo

    What is happening in this case is that your server(IIS) in case requests the aspx page which returns the value ad.wmv. Here is the complete flow - on IIS create a web Playlist and add an entry for relative path and set location to the aspx page. This is because the aspx page returns a relative path - ad.wmv (if you return a complete physical path set the location type accordingly). You should have ad.wmv in the same path on the IIS serveras the playlist.

    Related article:
    http://learn.iis.net/page.aspx/382/web-playlists-for-iis-70---creating-a-simple-playlist/

    Regards
    Vishal

  • Does the XML format work, or it needs to be SMIL?

Comments have been disabled for this content.