Silverlight Show: 10 Laps around Silverlight 5 (Part 4 of 10)

In this article, a discussion of media features such as low-latency sound using features right out of XNA. We will also discuss Remote Control and Media Command (Keys) support using Silverlight 5. Please review the Roadmap for the series before going any further.

The Roadmap for this Series

I’ve included the Roadmap for the series below as you may want to visit other sections as you learn Silverlight 5. I picked the following features as I thought that you may find them useful in your day-to-day work. If you want a specific topic covered then please leave it in the comments below.

  1. Introduction to SL5 – provides a brief history of Silverlight and relevant links.
  2. Binding - Ancestor Relative Source Binding and Implicit Data Templates.
  3. Graphics - XNA 3D API and Improved Graphics Stack.
  4. Media [This Post] - Low-Latency Sound using XNA and Remote Control and Media Command (Keys) Support.
  5. Text - Text Tracking and Leading, Linked and Multi-column Text, OpenType Support, Pixel Snapped Text and TextOptions.
  6. Operating System Integration Part 1 - P/Invoke, Multiple Windows and Unrestricted File System Access in Full Trust.
  7. Operating System Integration Part 2 - Default Filename for SaveFileDialog, 64-bit browser support and Power Awareness.
  8. Productivity and Performance - XAML Binding Debugging, Parser Performance Improvements and Multi-core JIT for improved start-up time.
  9. Controls - Double and Triple click support, PivotViewer and ComboBox Type-Ahead.
  10. Other items - In-Browser HTML, PostScript and Tasks for TPL.

Let’s Begin with Low-Latency Sound using XNA SoundEffect

A new addition to Silverlight 5 is the ability to play low-latency sounds using the XNA SoundEffect class. This is very useful for kiosk or even games that need to play a certain sound over and over. In Silverlight 5, this is much easier than before (where people used various MediaElement hacks). You can now simply borrow the SoundEffect / SoundEffectInstance class from XNA.

Start with a new Silverlight 5 Project

Launch Visual Studio 2010 and select File –> New Project. Then select Silverlight –> Silverlight Application –> Give it a name and hit OK.

On the New Silverlight Application Screen, you will see under “Options” that you may select which version of Silverlight that you want to use. We will select Silverlight 5 for this option. If you don’t see Silverlight 5 as an option then follow the guide here.


Read the full post