Microsoft Silverlight
Besides, many other Eduzendium articles welcome your collaboration! |
Microsoft Silverlight, previously known as Windows Presentation Foundation/Everywhere, is Microsoft's flagship cross-platform, cross-browser web client runtime for developing rich interactive applications such as graphics, animations and video playback. Silverlight extends the web development technique beyond the limitations of traditional HTML and JavaScript.
History
In order to create powerful web applications targeted for major platforms and Web browsers and deliver the next generation of .NET based media experiences and rich interactive applications for the Web, Microsoft developed Silverlight.
In 2003, Microsoft is developing a technology called Windows Presentation Foundation (WPF), formerly code-named Avalon. It is the graphics engine which is implemented in Vista. As the needs for a more powerful web application and Rich Interactive Applications (RIAs) increases, Microsoft uses its WPF technology to develop a powerful media plug-in targeted for major platforms, such as Windows,Mac OS X, and Linux (Moonlight), and Web browsers and deliver the next generation media experiences and .NET based RIAs for the Web.
In September 2007, Microsoft launched Silverlight 1.0. Silverlight 1.0 is built based on XAML (Extensible Application Markup Language) and JavaScript. It runs under the .NET Framework 3.0. It has a code behind written in JavaScript. Industry standard video and audio coded, such as VC-1, WMV, MP3 and WMA, are supported by Silverlight. Silverlight 1.0 did not take long to become a big hit in the media plug-in industry. However, Silverlight 1.0 has several limitations, such as limited built-in User Interface controls and developers can only use javascript as the code behind. Some third party compilers such as Script#, which compiles C# source code into JavaScript, try to work around these limitations.
In response to Silverlight 1.0 limitation, Microsoft introduced Silverlight 1.1 Alpha. In November 2007, Microsoft announced that they were renaming Silverlight 1.1 to Silverlight 2.0. Silverlight 2.0 is currently available as a beta version (Silverlight 2.0 Beta 2). Silverlight 2.0 is the same as Silverlight 1.0 with more built-in User Interface controls and supported by more programming languages such as, C# and Visual Basic.
With the enhanced capabilities and User Controls, Silverlight has gained more and more popularity since it was first released in September 2007. It is used to power the unprecedented online experience NBC Universal is creating for the 2008 Beijing Olympics [1].
Technology
Standard
Silverlight doesn't comply existing standards. Instead of using the W3C's SVG standard for vector graphics, Microsoft created its own XML-based vector graphics subset for XAML that is structurally similar to SVG. Since the SVG standard is widely used and supported by many applications and development technologies, the strategy of building a completely independent XML-based language for vector graphics limits the extent to which XAML developers can use or adapt existing third-party tools and technologies that are designed to work with SVG, and also limits the power of Silverlight to catch up with browsers that are more functional and standards-compliant. [2]
Features
The main features of Silverlight version 2.0 are as follows: [3]
- Create and manage 2D graphics and animation
- Handle mouse, keyboard, and ink input
- Deliver WMV, WMA, and MP3 media
- Work with JPEG and PNG imaging
- Format and manipulate text
- Communicate with services and download server resources by using the HTTP downloader
- Parse Extensible Application Markup Language (XAML) content and markup
- Navigate Web content by utilizing the JavaScript Document Object Model (DOM)
- Support for managed code such as C#, VB, Python and Ruby
- XAML extensibility
- Control class and sample controls
Examples
How to make an animation using Silverlight?
Creating an animation in Silverlight is different from Flash. The first step to animate an object in Silverlight is to create a Storyboard. Storyboard is an object in Silverlight which controls animations with a timeline. It is equipped with interactive methods to start, stop, pause and resume an animation. There are several type of animations in Silverlight. DoubleAnimation, ColorAnimation, and PointAnimation are the basic type of animations.
DoubleAnimation animates the value of a double property between two target values using linear interpolation over a specified duration. An example of DoubleAnimation is the type of animation which makes use of the opacity property of the object, since opacity property is of type double.
ColorAnimation animates the value of a color property between two target values using linear interpolation over a specified duration. This type of animation is used to animate the colors of its objects.
PointAnimation animates the value of a point property between two target values using linear interpolation over a specified duration. An animation that moves objects or enlarges objects is the type of animation which falls into PointAnimation category.
The more advance types of animations in Silverlight incorporate a set of KeyFrames. DoubleAnimationUsingKeyFrames, ColorAnimationUsingKeyFrames, PointAnimationUsingKeyFrames, and ObjectAnimationUsingKeyFrames are the advance types of animations. Each of these types of animations animates the value of its object property (such as double, point, color, and object) along with a set of KeyFrames over a specified duration.
An example of simple animation created in Silverlight 2.0 Beta 2 can be found in this link http://nikolas6.com/SilverlightSample/SilverlightSample.html.
The easiest way to create a Silverlight animation is by using Microsoft Expression Studio, in particular Expression Blend 2.5 June Preview (latest version of Expression Blend), and Microsoft Visual Studio 2008. The Expression Blend is used to design the layout and most of the stuffs related to the XAML, while the Visual Studio 2008 is used to edit the supported C# code.
In the case of the sample animation above, it uses two still images, which are then shown in sequence to create the illusion of a motion. The first step in doing this is to create a new Silverlight 2 Application project in Expression Blend. It will automatically generate two XAML files called App.xaml and Page.xaml. Each of these files contains a C# code behind, App.xaml.cs and Page.xaml.cs. Furthermore, Page.xaml contains a UserControl and Grid (named "LayoutRoot") objects by default. Once the project files are created, the two still images are then imported to the project folder, which can be done by either selecting the "Add Existing Item" option under "Project" or dragging the images into the Expression Blend project. The images are then inserted into the Grid (LayoutRoot). A Storyboard object is needed to create an animation. So, the next step is to add a new Storyboard to the project. The Storyboard has a time line property which allows user to set how objects behave for a specific duration. At time 00:00:00 (hour:minute:second) set QuestionMark2.jpg file to be visible and QuestionMark1.jpg file to be not visible. Then, at time 00:00:01, change the setting to QuestionMark2.jpg file be not visible and QuestionMark1.jpg file be visible. And finally, at time 00:00:02, set QuestionMark2.jpg file back to be visible and QuestionMark1.jpg file to be not visible. With this interchanging sequences of behavior, the two still images create an illusion of one image that has a motion, just like the example found in this link http://nikolas6.com/SilverlightSample/SilverlightSample.html. To have the behavior repeated several times or forever, Storyboard has a property called "RepeatBehavior" which can be set to 1x, 2x, 3x, and forever. Once the animation is set up, the Storyboard must be set to start the time line. This can be done by editing the code behind Page.xaml.cs. Right click the Page.xaml and select "Edit in Visual Studio". This will open Visual Studio and the solution in which the Page.xaml belongs to. In this case, to start the Storyboard, the code behind should look like the following:
namespace SilverlightApplication2 {
public partial class Page : UserControl { public Page() { // Required to initialize variables InitializeComponent(); Storyboard1.Begin(); // Start the Storyboard } }
}
Once the modification is done in the code behind, save, rebuild and test the solution.
How to put Silverlight into a web page?
When Silverlight application is compiled, it generates a file type, .xap, in the Bin folder of the project. It is basically a compiled Silverlight application, just like the .swf file in Flash. A .xap file contains an application manifest file, AppManifest.xaml, and .dll files [4].
To embedded the Silverlight application into a web page, the easiest way is to embed the following code into the HTML page.
<object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%"> <param name="source" value="SilverlightSample.xap"/> </object>
In the above code, SilverlightSample.xap is the Silverlight application which are embedded into the web page.
Market
Why and Where to use Silverlight?
The main reasons of people using Silverlight are as follows: [5]
- Silverlight supports playback of WMV files, full-screen 720p video and seamless transitions between full-screen and windowed mode without losing the position in the video.
- By separating markup (XAML) from code, Silverlight provides a familiar web metaphor for designers and developers. People can embed XAML directly into HTML pages.
- Silverlight is lightweight, which is just a 1MB download on a PC
- Silverlight is blindingly fast. For example, people can play many videos simultaneously without stuttering or dropping frames.
The same as Flash, Silverlight technology mainly focus on Internet. It supports multiple platform including Windows, Max OS X and Linux, and many browsers including IE, Firefox, Safari and Opera. As mentioned before, Silverlight 2.0 is used to broadcast over 2000 hours of the 2008 Summer Olympic Games. Also, Nokia has signed up to use Microsoft’s Silverlight platform for its S60 and S40 mobile devices as well as its Nokia Internet tablets, marking the first mobile win for the Redmond giant’s rich media development framework. [6]
Although there is no official survey about the percentage of Silverlight installation, the profit of selling server and development tools has reached $3 billion or about 25% of Microsoft's revenue in Q4 2007(ended 6/30/2007), which shows strong potential for Silverlight to take a place in market share. [7]
Allies and Competitors
The relationship of Silveright to other applications
Competitors
Silverlight aims to compete with Adobe Flash and the presentation components of Ajax. It also competes with Sun Microsystems’ JavaFX, which was launched a few days after Silverlight. Some people claim that as the future choice of developers who build rich Internet applications, Silverlight makes Flash/Flex look like an absolute toy. [8]
Future Developments
The problem is everything else. Can Microsoft truly be trusted to commit themselves to a cross-platform environment with an equally rich experience across platforms? History says no. And even it could be trusted the fact is that it’s Google that is showing leadership where Microsoft should be. Its Google thats taking the fight to Viacom. If any company in the tech industry is in a position to dictate to old media the terms of fair use and stand up and tell them - not ask - that the new paradigm is more sharing not less, it’s Microsoft. But it doesn’t, instead it tries to push DRM and kowtow to the media industry for some inexplicable reason. What we need from Microsoft is to stop acting like the rest of the tech industry is its enemy and assume a position of leadership. Instead, Microsoft comes out with another kickass developer suite, its been doing that since the 80’s, why you find that impressive is beyond me.
Reference
- ↑ Microsoft "Bill Gates Explores Past, Present and Future of Application Development at Tech•Ed North America 2008 Developers"
- ↑ Paul, Ryan. "Microsoft's Flash-killer Silverlight steals the show at MIX07"
- ↑ "An Overview of Silverlight"
- ↑ Pietschmann, Chris. "Silverlight: Anatomy of an .XAP file"
- ↑ Sneath, Tim. "Introducing Microsoft Silverlight"
- ↑ Higginbotham, Stacey. "Silverlight Goes Mobile With Nokia"
- ↑ Marshall, Kevin. "Silverlight Market Share"
- ↑ Arrington, Michael. "Why Silverlight Is Important"