<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.iis.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Prakash Duggaraju&amp;#39;s Blog</title><subtitle type="html" /><id>http://blogs.iis.net/prakashd/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.iis.net/prakashd/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.iis.net/prakashd/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2008-02-27T21:13:00Z</updated><entry><title>Writing Custom Playlist providers </title><link rel="alternate" type="text/html" href="http://blogs.iis.net/prakashd/archive/2008/04/21/writing-custom-playlist-providers.aspx" /><id>http://blogs.iis.net/prakashd/archive/2008/04/21/writing-custom-playlist-providers.aspx</id><published>2008-04-22T01:10:00Z</published><updated>2008-04-22T01:10:00Z</updated><content type="html">&lt;P mce_keep="true"&gt;&lt;A href="http://blogs.iis.net/blogs/prakashd/providersample.zip"&gt;&lt;A href="http://blogs.iis.net/blogs/prakashd/providersample.zip"&gt;providersample.zip&lt;/A&gt;providersample.zip&lt;/A&gt;The idea of this blog is to show the extensibility model of the Web Playlists feature.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;The playlist&amp;nbsp;&amp;nbsp;feature consits of two indepdent components that communicate via a well defined API boundary&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;A playlist handler - That handles all the playlist requests. The handler is a reqular IIS request handler and maps certain known extensions as playlists. It is responsible for rendering the playlist into an ASX output, managing the session and processing the individual entries in the playlist.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;One or more playlist providers&amp;nbsp;- A provider is a standalone COM component that&amp;nbsp;provides the actual&amp;nbsp;playlist information.&amp;nbsp; Each provider is registered to handle requests for one file extension (though you could register your provider for multiple extensions) .&amp;nbsp; The handler asks the&amp;nbsp;provider for the playlist information and then&amp;nbsp;uses it to render&amp;nbsp;playlist and process the entries in the playlist.&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;The&amp;nbsp;handler access the provider via COM interface though the actual provider implementation can be done in COM (VC++, VB) or managed code (C#, VB.Net).&amp;nbsp; To understand this further let me illustrate a sample provider that works as a wrapper playlist generator.&amp;nbsp; The idea of wrapper playlist is to wrap each requested video file with an advertisement (which cannot be skipped/seeked).&amp;nbsp; For example you webpage has a video called tutorial.wmv.&amp;nbsp;&amp;nbsp;You need to reigster your provider for a unique extension (say .wpl) &amp;nbsp;and your webpage needs to be updated to refer tutorial.wpl.&amp;nbsp; When the&amp;nbsp;user opens this link,&amp;nbsp;the handler will send an ASX file with two entries (first a predefined adverstiment) and then the actual video.&lt;/P&gt;
&lt;P mce_keep="true"&gt;If you are wondering why you need a separate file extension for playlist (and not re-use the original file extension) then, that is due to support for nested playlists. If the playlist is called a.wmv and the entry in the playlist is &amp;nbsp;b.wmv the handler decides wether it is a regular entry or nested palylist based on the extension. If you think&amp;nbsp;it is a bit of pain to update the URLs in your pages you could write an additional IIS module to rewrite the URLs (or wait for the upcoming IIS re-write module :-) )&lt;/P&gt;
&lt;P mce_keep="true"&gt;Implementing a playlist provider is very straight forward. You implement a COM Component that implements IPlaylistProvider interface.&amp;nbsp; The interface needs to implement just 3 methods&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Initialize - Called when the provider is loaded (on the first request). A place holder for one time initialization&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Shutdown - Called when the IIS worker process is going down. A Place holder for resource cleanup.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;GetPlaylistInfo - The real logic lies in this method that maps a request to a playlist object.&amp;nbsp; The provider returns a IPlaylistInfo object that describes a playlist. The Playlist handler uses the IPlaylistInfo object returned by the provider to render the response as well as validate the individual entries in the playlist. Below is code from sample provider:&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IPlaylistInfo IPlaylistProvider.GetPlaylistInfo(IPlaylistRequestInfo requestInfo)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String path = requestInfo.Path;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String name = path.Substring(path.LastIndexOf('/') + 1);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = name.Substring(0, name.LastIndexOf(".")) + ".wmv";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new PlaylistInfo(Advertisement, name);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The logis&amp;nbsp;is just replacing .wpl with .wmv though the actaul media file could .flv or .mp4 or any other valid media file format.&lt;/P&gt;
&lt;P mce_keep="true"&gt;The IPlaylistRequestInfo passed to the provoider is a simple COM wrapper on top of &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms689291.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms689291.aspx"&gt;IHttpContext&lt;/A&gt; and exposes some of the useful underlying information.&amp;nbsp; The Path property for example give the path of the request URL (/tutorial.wpl in this case). The IPlaylistRequestInfo has methods to Get/Set a server variable (and thus interact with other IIS modules) and also a way to store/retrieve session state ( in a String form).&lt;/P&gt;
&lt;P mce_keep="true"&gt;The IPlaylistInfo is an interface to describe the palylist. You need to create an object impleting this interface. The IPlaylistInfo has the following methods that need to be implemented&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;GetProperty - Return properties of the playlist like title, copyright, timeout etc&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Entries - Return a IPlaylistEntryInfoCollection object to enumerate over the entries in the playlist. &lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;The next interface to be implemented is the IPlaylistEntryInfoCollection. It&amp;nbsp;just has two propetries&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Count - the no. of entries in the playlsit and&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Item - the information about the actual entry.&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;The next interface that needs to be implemented is the IPlaylistEntryInfo interface. You need to return an object of this interface for each entry in the playlist. This interface has the following methods&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;GetProperty - The properties of this entry i.e wether user can seek/skip forward/skip backward, title etc.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;EntryType - An enumeration on how the actual media file is located i.e physical path, relative path, remote URL etc&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Uri - The actual location of the media file. If the path is a realtive path then the Playlist handler with do the mapping from relative to absolute path before returning the file and you don't have to bother about the&amp;nbsp;directory structrue and other details.&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;You need to know some points about the contract&amp;nbsp;between the&amp;nbsp;handler and&amp;nbsp;the provider&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;For a&amp;nbsp;playlist you cannot change the no. of entries in the playlist after the initial request. This is because there is no way to change the ASX sent already to the client.&amp;nbsp; Though the actual file returned for&amp;nbsp;each playlist can be changed with each call.&amp;nbsp; However if the same playlist is requested again (by same or different user) then no. of entries need not be the same.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;If you want a dynamic playlist with unlimited no. of entries you can use nested playlists&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;For nested playlists the Path&amp;nbsp;property of the IPlaylistRequestInfo object will point to the nested playlist (And that should be used instead of relying on the SCRIPT_NAME server variable)&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;The IPlaylistFileInfo&amp;nbsp;object is available on when the actual&amp;nbsp;playlist is a physical file on disk and&amp;nbsp;the handler is registered as&amp;nbsp;a file handler.&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;The zip below contains the sample code (implemented both as managed/COM provider). The solution file included is for Visual Studio 2008 though the source code should work on Visual studio 2005 as well. To&amp;nbsp; use the sample you need to copy the playlisthandler.dll from the playlist install to the directory where the solution file (.sln) is present. The file is under %PROGRAMFILES%\IIS\Media on an installed machine.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A href="http://blogs.iis.net/blogs/prakashd/providersample.zip"&gt;providersample.zip&lt;/A&gt;&amp;nbsp;(&lt;EM&gt;The samples in this blog are provided as is with no warranties, and confer no rights. The views expressed in this blog are entirely my own and not of my employer. I currently work for Microsoft)&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2312191" width="1" height="1"&gt;</content><author><name>prakashd</name><uri>http://blogs.iis.net/members/prakashd.aspx</uri></author></entry><entry><title>Web playlists - A brief introduction </title><link rel="alternate" type="text/html" href="http://blogs.iis.net/prakashd/archive/2008/02/27/web-playlists-a-brief-introduction.aspx" /><id>http://blogs.iis.net/prakashd/archive/2008/02/27/web-playlists-a-brief-introduction.aspx</id><published>2008-02-28T05:13:00Z</published><updated>2008-02-28T05:13:00Z</updated><content type="html">&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;P&gt;Today we released the first Customer Technology Preview of the web&amp;nbsp;playlist module for IIS 7.0.&amp;nbsp; This addition to&amp;nbsp;our media initiatives&amp;nbsp;for IIS, along with the earlier released bit-rate throttling module, provide administrators with a powerful way of delivering rich media to the end users.&amp;nbsp;&amp;nbsp;It also enables them&amp;nbsp;to monetize the&amp;nbsp;same (e.g., by&amp;nbsp; inserting ads&amp;nbsp;that are guaranteed to be played&amp;nbsp;).&lt;/P&gt;
&lt;P&gt;&lt;B&gt;What is a Playlist?&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;A playlist&amp;nbsp;is a sequence of media elements (audio/video/pictures), created either statically or dynamically.&amp;nbsp; Typically administrators like to to control the sequence of media viewed by&amp;nbsp;users. Administrators might also want to enforce further restrictions on the individual entries in the playlist.&amp;nbsp;&amp;nbsp;For example,&amp;nbsp;administrators&amp;nbsp;might want&amp;nbsp; an advertisement&amp;nbsp;to be viewed completely without the user being able to seek or skip through&amp;nbsp;it.&amp;nbsp; Playlists usually come in two flavors: &lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI&gt;Client side playlists.&lt;/LI&gt;
&lt;LI&gt;Server side playlists&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;B&gt;Client side playlists&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;In the client side playlist scenario the&amp;nbsp;server sends down the playlist&amp;nbsp;to the client.&amp;nbsp;This is typically a plain text or an XML file.&amp;nbsp; The client parses the file, reads the entries in the file and then requests the entries in the order they are present in the file.&amp;nbsp; A properly written client would respect the order of entries and any other restrictions placed in the playlist like, "no skip" , "no seek", and so on.&amp;nbsp; A rogue client, however, could just ignore such restrictions and give users full control. The server has least control on what the client does.&amp;nbsp; Client side playlists are simple to implement and administer, and can&amp;nbsp;be very easily generated using dynamic web pages.&amp;nbsp; No special server support is required.&amp;nbsp; In addition,&amp;nbsp;a wide range of clients and formats can be supported easily. Most commonly used client side playlist formats&amp;nbsp;are the m3u&amp;nbsp;for mp3 playlists, and the ASX format for the windows media.&amp;nbsp; Synchronized Multimedia Integration Language, SMIL, is the&amp;nbsp;W3C recommended playlist format, but&amp;nbsp;not all clients support it.&amp;nbsp; Another disadvantage of client side playlists is that&amp;nbsp;they expose the entries completely to the end user. It also means that the individual entries in the playlist need to the accessible in your URL namespace.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Server side playlists&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Server side playlists try to overcome the limitations of client side playlists by implementing the playlist functionality entirely&amp;nbsp;on the server side.&amp;nbsp; The clients do not even know how many entries are present in the playlist and what they are. The server can strictly enforce any restrictions it wants on the entries.&amp;nbsp; However this needs&amp;nbsp;a special understanding between the clients and the server (usually at the protocol level).&amp;nbsp; This usually means server side playlist implementations are restricted to specific client implementations and/or media formats.&amp;nbsp; For example the server side playlist implementation in the windows media services supports only Windows Media format and only supports Windows Media clients. With server side playlist the media location is hidden from the clients and there is no way clients could directly request the media to overcome the playlist restrictions.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Where does web playlist fit in?&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Web playlist feature in the IIS tries to bring the best of both worlds together by using a&amp;nbsp;hybrid approach.&amp;nbsp; It presents a client side playlist to the clients but the playlist is enforced and validated on the server side as well.&amp;nbsp;Thus administrators&amp;nbsp;are not limited to the kind of media formats or clients&amp;nbsp;they can use to deploy in their applications and at the same time they can be sure that any restrictions they want to&amp;nbsp;place in the playlist are enforced&amp;nbsp;and&amp;nbsp;is not at the mercy of the client implementation. At the same time web playlists make sure that the individual media entries are not exposed to the end users&amp;nbsp;and&amp;nbsp;they need not be accessible in the URL namespace.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;B&gt;How does web playlist work?&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;So how does the web playlist feature in IIS work? The functionality is implemented via a special request handler in the IIS pipeline.&amp;nbsp; The administrators create playlists on the server side using IIS Admin interface.&amp;nbsp; The playlist request handler is registered to serve these special files.&amp;nbsp; On the first request the handler reads the server side playlist and creates an equivalent&amp;nbsp;client side playlist and sends to the client.&amp;nbsp; However the created client side playlist does not expose the individual media elements in the playlist. The playlist consists of&amp;nbsp;special encoded URLs that only the playlist handler can understand and serve.&amp;nbsp; Further the playlist handler maintains the restrictions placed on the entries in its session state and enforces them on the server side.&amp;nbsp; So a rogue client could send a seek request on an entry it is not supposed to seek, but the server will validate and fail such requests.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;What is the extensibility story?&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;While this looks interesting having simple static playlists with fixed entries on the server is very restrictive&amp;nbsp;and lot of maintenance overhead for the administrators.&amp;nbsp; The web playlist has a solution for this too. The playlist module has an extensible provider framework.&amp;nbsp; So you could write code (either native or managed) that could generate the playlists dynamically. In fact the playlist need not be a physical file on the disk but could be queried from an external source (like a database) if one wishes to.&amp;nbsp; In the next release we will be publishing the APIs on how customers could write their custom playlist providers that could serve a rich set of content in a wide variety of formats to a wide spectrum&amp;nbsp;of clients.&amp;nbsp; So do keep looking for further updates on this module :-).&lt;/P&gt;
&lt;P&gt;The playlist feature can be configured to use the ASP.NET session state management. This way the playlist state can be maintained and restored irrespective of server failures.&amp;nbsp; The playlist module works very well together with the already released bit-rate throttling module. Combined together they could turn your web server in to a powerful platform for delivering media content in a way that is&amp;nbsp;powerful, scalable, extensible and yet very cost effective.&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2200557" width="1" height="1"&gt;</content><author><name>prakashd</name><uri>http://blogs.iis.net/members/prakashd.aspx</uri></author><category term="IIS media web playlists bitrate throttling" scheme="http://blogs.iis.net/prakashd/archive/tags/IIS+media+web+playlists+bitrate+throttling/default.aspx" /></entry></feed>