MSN Video IE Accelerator Tutorial

accelerator_60 You’ve probably already seen how Internet Explorer 8 Accelerators allow you to perform searches very quickly on the web. What about going one step ahead, showing a video preview instead of a “plain text” result? Check out the result!

A- Add the MSN Accelerators

Add MSN Video Accelerator


B – Test it here :-)

  • Hello World
  • Dream Theater
  • Metallica
  • Bon Jovi
  • Bill Gates
  • Roberto Benigni
  • Back to the future
  • Ask a ninja


C – Look and download the code

image Now that you’ve seen the accelerator in action, let’s have a look at the code behind.

You will notice that – for this sample – I’ve written only client side code (Javascript), using the free Visual Web Developer 2008.

The complete source code of this sample is available here.


 <openServiceDescription xmlns="">
     <name>Play with MSN</name>
   <activity category="Play">
     <activityAction context="selection">
       <preview action="http://localhost/MsnAccelerator/MsnPreview.htm?sel={selection}" />
       <execute action="http://localhost/MsnAccelerator/MsnSearch.htm?q={selection}" >

The Accelerator descriptor contains the details of our accelerator. In this case we are creating a new accelerator in the custom category “Play”; the accelerator will send the selected text to MsnPreview.htm page through the sel parameter.


This page will be called when the user click on the “Play with MSN” menu; in this scenario I’m redirecting the user to the existing search page on the website (providing the current search keyword in the querystring).


The code required to add the accelerator is easy as follow.

 <button onclick="window.external.AddService('MSN.xml')">
             Add MSN Video Accelerator


The preview is probably the most interesting and powerful part of an accelerator, since it can show really rich content using any client language (HTML, Javascript, Silverlight, Flash, ….).

In this scenario I’m performing the following operations using Javascript, in order:

  1. Get user selection
  2. Search video on
  3. Build player control

Let’s break it down to functional pieces.

1- Get user selection: the selected text is provided to the preview page through the sel parameter of the querystring, as described previously.

 function getQueryStringParameter(param) {
             var qs =;
             var ps = qs.split("&");
             for (i = 0; i < ps.length; i++) {
                 var p = ps[i].split("=");
                 if (p[0] == param) {
                     return p[1];
             return null;
         window.onload = searchVideo;

2- Search video on

Going around the site, I found that the following url perform a search on, returning the result as RSS feed.\&responseEncoding=rss

Due to cross-domain restriction with the server (remember, we are doing the call client side here), I created a pipe (using Yahoo Pipes) that will return the result of my query using JSON format. Note that this is just one of the possible ways to do this; if the server supported cross-domain requests, I would used instead the new XDomainRequest.

 function searchVideo() {
             var selection = getQueryStringParameter("sel");
             if (selection != null) {
                 var newScript = document.createElement('script');
                 newScript.type = 'text/javascript';
                 newScript.src = ''
                             + selection +
         function getVideo(feed) {
             var result = feed.value.items;
             if (result != null && result.length > 0)
             else {
                 setContent('No result found.', true);

As you can see in the following picture, the pipe will get the feed, extract the first item and return only the guid value through the designated callback.


3- Build player control

The last step, given the id of the video, is to build dynamically the video player and add it to the page.

 function buildVideo(id) {
             var video = document.createElement('embed');
             video.src = '';
             video.type = "application/x-shockwave-flash";
             video.flashvars = "c=v&v=" + id + "&ifs=true&ap=true"
             video.width = "320px";
             video.height = "240px";
             video.allowfullscreen = "false";

That’s it! With a bunch of JavaScript code, I now have a very powerful accelerator.

The complete source code of this sample is available here.

D – Next step

Exercise to the reader: it would be interesting to improve the UI and show more than one video result, maybe using Silverlight ;)

If you want to know more about IE8 Accelerators or you want to build your own, I recommend reading the following resources:



Technorati Tags: IE8,IE,Accelerators


Disclaimer: the accelerator in this post is not supported by the writer, neither by MSN or Microsoft. They are rather provided as is, for the sake of learning and having fun :-)