Archives / 2010 / October
  • Control a Silverlight Media player in IE9 from Windows 7 taskbar


    Following my article on IE9 and Windows 7 integration, here is how you could go further by controlling an IE9 hosted Silverlight video from Windows 7 taskbar.

    Live demo

    If you have IE9 on Windows 7, you can try a live demo by visiting and dragging the browser tab to your taskbar, then select “Connected Experience” from the JumpList. (I explain how to create such a list in my previous article).


    This opens IE9 with a web page containing a Silverlight video:


    Note that you get a live preview in the taskbar’s thumbnail, and you can control the video!



    How to build this experience ?

    With a bit of JavaScript, and the knowledge to communicate between the browser and Silverlight.


    Silverlight project

    1. In my XAML page I have a MediaElement with x:Name="MediaPlayer", so I just need to add 2 methods with the ScriptableMember attribute in code behind:

    public void Play()
    public void Pause()


    2. Then expose the page instance (as “MyPlayer”) to JavaScript, see line 4 of the following code:

       1: public MainPage(object sender, StartupEventArgs e)
       2: {
       3:     InitializeComponent();            
       4:     HtmlPage.RegisterScriptableObject("MyPlayer", this);
       5: }


    With these two steps I am able to call the C# methods from JavaScript.


    Web Site

    1. In the HTML (or aspx) page that hosts Silverlight add the following META tag:

    <meta http-equiv="X-UA-Compatible" content="IE=9" />


    2. Add some JavaScript:

       1: <script type="text/javascript">
       2:     window.onload = function() {
       3:         var host = document.getElementById("SLObject");
       5:         btn1 = window.external.msSiteModeAddThumbBarButton('Play.ico', 'Play');
       6:         btn2 = window.external.msSiteModeAddThumbBarButton('Pause.ico', 'Pause');
       8:         document.addEventListener('msthumbnailclick', btnHandler, false);
       9:         function btnHandler(e) {
      10:             if (host) {
      11:                 if (e.buttonID == 1)
      12:                     host.Content.MyPlayer.Play();
      13:                 if (e.buttonID == 2)
      14:                     host.Content.MyPlayer.Pause();
      15:             }
      16:         }
      17:         window.external.msSiteModeShowThumbBar();
      19:         window.external.msSiteModeUpdateThumbBarButton(btn1, true, true);
      20:         window.external.msSiteModeUpdateThumbBarButton(btn2, true, true);
      21:     }
      22: </script>


    Line 3: SLObject is the Id of my Silverlight object tag.

    Lines 5 and 6: Create 2 buttons

    Line 17: Instantiate them

    Lines 19 and 20: Set both buttons visible and enabled.


    Now you will automatically get 2 buttons in the live thumbnail from the Windows 7 taskbar, and be able to play/pause the Silverlight video!


    The only thing I wasn’t able to do is installing the Silverlight app Out-Of-Browser right from the thumbnail.
    I think because Application.Current.Install(); must be called from a user initiated event (mouse or keyboard event in Silverlight).


    Technorati Tags: ,,

  • Speaking at TechDays Canada 2010


    This year again I’ll be speaking at TechDays Canada!

    I will take care of 3 talks in Montreal on November 23-24:


    DEV302: A Lap around Windows Internet Explorer 9 for Developers
    Wednesday, November 23, 12:30pm to 12:50pm

    Internet Explorer 9 contains many new features that give developers many new options for building rich Web applications. From enhanced features like the developer tools or support for more DOM interactivity – Internet Explorer 9 is the browser you’ve been asking for. In this TurboTalk you will learn about these features and how you can take advantage of brand new APIs like HTML5, SVG, and Direct2D Graphics support.”


    OPT217: Speeding up Silverlight development using 3rd Party Controls
    Wednesday, November 24, 12:30pm to 12:50pm

    “Learn how to cut Silverlight development time significantly using your new Telerik RadControls. As a TechDays attendee, you will receive a complimentary license for Telerik’s RadControls for Silverlight. This TurboTalk will demonstrate how you can speed up application development while adding more functionality to your Silverlight applications with the Telerik tools. See how high-performance data controls like RadGridView and RadChart can take your applications to the next level. See how layout controls like RadDocking and RadTileView can add both richness and increased functionality, helping you maximize screen real estate. And see how RadRichTextBox is unlocking Silverlight’s power to enable editing of HTML, DOCX, and XAML content. Jumpstart your development with the RadControls for Silverlight and get the most out of your new tools by joining this developer-to-developer talk.”


    Breakout: A Lap Around Visual Studio LightSwitch
    Wednesday, November 24, 3:40pm to 4:45pm

    LightSwitch is a newcomer in the Visual Studio suite and allows you to create Silverlight business applications with little or no code. Discover this tool via a demo and be amazed like I am, also you will learn how to customize and extend its capabilities. Wow effect guaranteed!”

    Early bird price is expired, but if you plan to register contact me as I can give you a 50% off coupon.

    See you there!


  • Silverlight Firestarter event in December

    Light up your Silverlight skills with the all-new Global Silverlight Firestarter!

    Silverlight FirestarterWhat is the Silverlight Firestarter?

    • An Event: A one day, global, live streamed and on demand event keynoted by Scott Guthrie
    • Training: New self-paced labs and walk through videos
    • Interactive: Got questions? Get your answers! Watch live and ask the Silverlight product team questions during the event.
    • Why Silverlight? Silverlight is Microsoft’s strategic development platform for building interactive applications across desktop, phone, and the browser.

    Something for Everyone

    • Just starting out with Silverlight? Watch the On-Ramp sessions and work on hands on labs to get you started.
    • Already Building business applications? Watch the event live and learn how to create compelling business applications with Silverlight.
    • Got questions? Engage with the Silverlight product team live or in person with our interactive chat.

    When: December 2, 2010 8am to 5pm PT

    Register: Register Online, Now!

    How Much? Nothing! This is a free event


    8:00 am
    Silverlight Firestarter Keynote
    Scott Guthrie

    9:00 am
    Masterful Data Strategies with Silverlight and WP7
    Jesse Liberty

    10:00 am
    15 minute break

    10:15 am
    Roll Out Your Business Apps Today with RIA Services
    Pete Brown

    11:15 am
    MVVM: Why and How? Tips and Patterns using MVVM and Service Patterns
    John Papa

    12:15 pm
    Lunch break

    1:00 pm
    Silverlight Today and Tomorrow (Special Guest Panel)

    1:30 pm
    Building Real World Silverlight Apps
    Tim Heuer

    2:30 pm
    15 minute break

    2:45 pm
    Tune Your Application: Profiling and Performance Tips
    Mike Cook & Jossef Goldberg

    3:45 pm
    Killer Performance Tips for Silverlight Windows Phone 7
    Jaime Rodriguez

    5:00 pm
    After Party!


    More info: