DAVIDEVANS.COM
 PHOTO GALLERIES FOR THE EVANS FAMILY ON THE WEB SINCE 1995
Sunday 05
September 2010
Sign In
Blog Silverlight Blog Entries
Tuesday 19 January 2010   
Silverlight
Telerik RadMediaPlayer

Hi,

I recently had the opportunity to use Telerik's RadMediaPlayer control for Silverlight and ASP.NET applications.  Talk about easy.  In just a few lines of code, I could call a .wmv file and have an elegant UI for the streaming video (which you can see in action here).

Here's the XAML code:

<UserControl x:Class="radVideoTest.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

            xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.MediaPlayer"

    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

  <Grid x:Name="LayoutRoot">

            <telerik:RadMediaPlayer Width="720" Height="480">

                  <telerik:RadMediaItem Source="http://www.davidevans.com/userfiles/video/4thLaw.wmv"

                        ImageSource="http://www.davidevans.com/userfiles/video/4thLaw.jpg" Title="'4th Robot Law', by David Evans (3:17)">

                  </telerik:RadMediaItem>

            </telerik:RadMediaPlayer>

  </Grid>

</UserControl>


After you compile the XAML app you get a .xap file which you add to your project in a ClientBin directory.  Along with some other basics you then simply plop the object on the page like this:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

              <param name="source" value="ClientBin/radVideoTest.xap"/>

              <param name="onError" value="onSilverlightError" />

              <param name="background" value="white" />

              <param name="minRuntimeVersion" value="3.0.40818.0" />

              <param name="autoUpgrade" value="true" />

              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">

                    <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>

              </a>

          </object>


Couldn't be cleaner.

 

 

By the way, I just love that you can write XAML apps using C# .NET code behind.  You can't do that in Adobe Flash.

Cheers, D