Simple clear advice in plain English

Hands on: Putting Silverlight to work

Microsoft’s cross-platform plug-in now includes the .Net runtime

Microsoft Silverlight is a cross-platform browser plug-in that runs in Firefox, Safari or Internet Explorer on Windows and Mac OSX. Version 1.0 has been out for a while, offering embedded video and animation, but it’s version 2.0 that is interesting for programmers, since it includes the .Net runtime.

This means you can take Visual Basic or C# code and create a cross-platform web application. Silverlight 2.0 is in beta at the time of writing, but a full release is expected by the end of 2008. Only Intel Macs are supported, but this is still an interesting option for exploring the new world of rich internet applications.

What’s Silverlight good for?
Silverlight has several personalities. In one guise it’s a media player. For example, this line of XAML (the Silverlight layout language) defines a media element:

Although it is set to AutoPlay, nothing will happen when the page loads, because there is no media to play. However, you can start the music with a couple of lines of VB:
Dim theUri As Uri = New Uri(“/audio/test.mp3”, UriKind.Relative)
Me.slplayer.Source = theUri

Silverlight supports WMA and MP3 audio, and WMV video based on the VC-1 standard. The great thing about using it is there are no dependencies on other media players being installed.

Next, Silverlight enables rich designs and graphical effects that are hard or impossible to achieve in pure HTML. You can use it for individual elements on a page, such as a menu or animation, or you can expand it to fill the entire page.

One strength of Silverlight is that it is easy to interact with the host page. Imagine you were writing an RSS client in Silverlight and wanted to populate a DIV element with the HTML text of a blog post. This VB code will do it. Add an imports statement for System.Windows.Browser, then write:
Dim el As HtmlElement = HtmlPage.Document.GetElementById(“blogpost”)
el.SetProperty(“innerHTML”, theHtmlText)

Still, multimedia and design may not be the most significant thing about Silverlight, particularly since Adobe’s Flash covers much of the same ground and is more widely used. Silverlight is most interesting as an application platform. Its design and multimedia capabilities come in handy in this context too, but it is the ability to run .Net code within the browser that sets it apart.

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

Hands on: Data Basic

Investigate the different ways of handling databases in Visual Basic

Hands on: How to add a search feature to Microsoft Visual Studio

Add a search feature and display an image in Visual Studio

Hands on: Keep tabs on your website

Create a bespoke web monitoring and alert service with Visual Basic

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Restore point

A Windows backup of system files and settings.

Great shopping deals from Computeractive