<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paul Yanez &#187; mediaelement</title>
	<atom:link href="http://paulyanez.com/interactive/index.php/tag/mediaelement/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulyanez.com/interactive</link>
	<description>Interactive Design and Labs</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:51:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a Download Progress Bar for your Hulu inspired SilverLight video player</title>
		<link>http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/</link>
		<comments>http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 18:16:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[blend 3]]></category>
		<category><![CDATA[DownloadProgress]]></category>
		<category><![CDATA[DownloadProgressChanged]]></category>
		<category><![CDATA[HorizontalAlignment]]></category>
		<category><![CDATA[hulu]]></category>
		<category><![CDATA[mediaelement]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://paulyanez.com/interactive/?p=535</guid>
		<description><![CDATA[This is part 4 in our series of building a Hulu inspired video player. In this tutorial we will be building a download progress bar.
We will take the design of our download progress bar and set it&#8217;s width equal to the position of the video&#8217;s DownloadProgress property. To make this auto-update we will hook into [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 4 in our series of building a Hulu inspired video player. In this tutorial we will be building a download progress bar.<span id="more-535"></span></p>
<p>We will take the design of our download progress bar and set it&#8217;s width equal to the position of the video&#8217;s DownloadProgress property. To make this auto-update we will hook into the &#8216;DownloadProgressChanged&#8217; event.</p>
<p>1- Place a rectangle on the stage, on a layer below the progress bar<br />
2- Set the rectangle&#8217;s HorizontalAlignment to Left<br />
2- Set the rectangle&#8217;s color to white and its alpha to 20%<br />
3- On the DownloadProgressChanged event of the mediaElement we will execute code</p>
<p>The end result in code is: loadProgressBar.Width = mp.DownloadProgress * bar.ActualWidth;</p>
<p>View all parts of the tutorial<br />
Part 1 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/">Building a Play-Pause control</a><br />
Part 2 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/">Loading external video</a><br />
Part 3 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Progress Bar</a><br />
Part 4 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Download Progress Bar</a><br />
Part 5 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-control-for-your-hulu-inspired-silverlight-video-player/">Building a Volume Control</a><br />
Part 6 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-the-time-display-for-your-hulu-inspired-silverlight-video-player/">Building the Time Display</a><br />
Part 7 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-slider-for-your-hulu-inspired-silverlight-video-player/">Volume Slider control</a><br />
Part 8 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-start-playing-button-for-your-hulu-inspired-silverlight-video-player/">Start playing button</a></p>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="276"><param name="source" value="http://www.paulyanez.com/interactive/blog/DownloadProgress/downloadProgress.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40624.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/></p>
<p>		  </a><br />
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</p></form>
<p><font face="Georgia" color="#000000" size="4">XAML code</font></p>
<pre class="brush: xml;">

&lt;UserControl
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; xmlns:local=&quot;clr-namespace:HuluSilverLight&quot;
	x:Class=&quot;HuluSilverLight.MainPage&quot;
	Width=&quot;640&quot; Height=&quot;276&quot; mc:Ignorable=&quot;d&quot;&gt;
	&lt;Grid x:Name=&quot;LayoutRoot&quot; Margin=&quot;0,0,0,201&quot;&gt;
		&lt;MediaElement x:Name=&quot;mp&quot; Margin=&quot;0,-42,0,-240&quot; Source=&quot;http://www.paulyanez.com/interactive/blog/HD/darkknight.wmv&quot; DownloadProgressChanged=&quot;downloadProgressHandler&quot;/&gt;
		&lt;local:hulu_player Height=&quot;32&quot; Margin=&quot;0,0,0,-199&quot; VerticalAlignment=&quot;Bottom&quot;/&gt;
                &lt;Rectangle x:Name=&quot;progressBar&quot; Fill=&quot;#3EFFFFFF&quot; Height=&quot;30&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;46,0,0,-198&quot; VerticalAlignment=&quot;Bottom&quot; RenderTransformOrigin=&quot;0,0.5&quot; Width=&quot;{Binding Position.TotalSeconds, ElementName=mp, Mode=OneWay}&quot;&gt;
			&lt;Rectangle.RenderTransform&gt;
				&lt;TransformGroup&gt;
					&lt;ScaleTransform ScaleX=&quot;2.5&quot;/&gt;
					&lt;SkewTransform/&gt;
					&lt;RotateTransform/&gt;
					&lt;TranslateTransform/&gt;
				&lt;/TransformGroup&gt;
			&lt;/Rectangle.RenderTransform&gt;
		&lt;/Rectangle&gt;
	&lt;/Grid&gt;
&lt;/UserControl&gt;
</pre>
<p><font face="Georgia" color="#000000" size="4">C# code</font></p>
<pre class="brush: cpp;">

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HuluSilverLight
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
		}

		private void downloadProgressHandler(object sender, System.Windows.RoutedEventArgs e)
		{
			loadProgressBar.Width = mp.DownloadProgress * bar.ActualWidth;
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Progress Bar for your Hulu inspired SilverLight video player</title>
		<link>http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/</link>
		<comments>http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 12:32:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mediaelement]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[totalseconds]]></category>

		<guid isPermaLink="false">http://paulyanez.com/interactive/?p=522</guid>
		<description><![CDATA[This is part 3 in our series of building a Hulu inspired video player. In this tutorial we will be building a progress bar.
We will take the design of our progress bar and set it&#8217;s width equal to the position of the video&#8217;s current position. To make this dynamic and without needing to write any [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 3 in our series of building a Hulu inspired video player. In this tutorial we will be building a progress bar.<span id="more-522"></span></p>
<p>We will take the design of our progress bar and set it&#8217;s width equal to the position of the video&#8217;s current position. To make this dynamic and without needing to write any code we will use the concept of Binding.<br />
<a href="http://paulyanez.com/interactive/index.php/2009/11/databinding-controls-in-silverlight-3/"><br />
You can view a video on Databinding here</a><br />
1- Place a rectangle on the stage<br />
2- Set the rectangle&#8217;s HorizontalAlignment to Left<br />
2- Set the rectangle&#8217;s color to white and its alpha to 20%<br />
3- Bind the width property of the rectangle to the Position.TotalSeconds of the mediaElement</p>
<p>In design view<br />
Select the rectangle<br />
Click the yellow box next to the width property.<br />
Select &#8216;Databinding&#8217;<br />
Select the &#8216;Element Property&#8217; tab<br />
In the &#8220;Scene Elements&#8217; list, select the mediaElement control<br />
In the properties list select &#8216;Position / TotalSeconds&#8217;</p>
<p>The end result in XAML is:  Width=&#8221;{Binding Position.TotalSeconds, ElementName=mp, Mode=OneWay}&#8221;</p>
<p>View all parts of the tutorial<br />
Part 1 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/">Building a Play-Pause control</a><br />
Part 2 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/">Loading external video</a><br />
Part 3 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Progress Bar</a><br />
Part 4 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Download Progress Bar</a><br />
Part 5 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-control-for-your-hulu-inspired-silverlight-video-player/">Building a Volume Control</a><br />
Part 6 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-the-time-display-for-your-hulu-inspired-silverlight-video-player/">Building the Time Display</a><br />
Part 7 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-slider-for-your-hulu-inspired-silverlight-video-player/">Volume Slider control</a><br />
Part 8 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-start-playing-button-for-your-hulu-inspired-silverlight-video-player/">Start playing button</a></p>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="276"><param name="source" value="http://www.paulyanez.com/interactive/blog/ProgressBar/progressbar.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40624.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/></p>
<p>		  </a><br />
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</p></form>
<p><font face="Georgia" color="#000000" size="4">XAML code</font></p>
<pre class="brush: xml;">

&lt;UserControl
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; xmlns:local=&quot;clr-namespace:HuluSilverLight&quot;
	x:Class=&quot;HuluSilverLight.MainPage&quot;
	Width=&quot;640&quot; Height=&quot;276&quot; mc:Ignorable=&quot;d&quot;&gt;
	&lt;Grid x:Name=&quot;LayoutRoot&quot; Margin=&quot;0,0,0,201&quot;&gt;
		&lt;MediaElement x:Name=&quot;mp&quot; Margin=&quot;0,-42,0,-240&quot; Source=&quot;http://www.paulyanez.com/interactive/blog/HD/darkknight.wmv&quot; /&gt;
		&lt;local:hulu_player Height=&quot;32&quot; Margin=&quot;0,0,0,-199&quot; VerticalAlignment=&quot;Bottom&quot;/&gt;
                &lt;Rectangle x:Name=&quot;progressBar&quot; Fill=&quot;#3EFFFFFF&quot; Height=&quot;30&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;46,0,0,-198&quot; VerticalAlignment=&quot;Bottom&quot; RenderTransformOrigin=&quot;0,0.5&quot; Width=&quot;{Binding Position.TotalSeconds, ElementName=mp, Mode=OneWay}&quot;&gt;
			&lt;Rectangle.RenderTransform&gt;
				&lt;TransformGroup&gt;
					&lt;ScaleTransform ScaleX=&quot;2.5&quot;/&gt;
					&lt;SkewTransform/&gt;
					&lt;RotateTransform/&gt;
					&lt;TranslateTransform/&gt;
				&lt;/TransformGroup&gt;
			&lt;/Rectangle.RenderTransform&gt;
		&lt;/Rectangle&gt;
	&lt;/Grid&gt;
&lt;/UserControl&gt;
</pre>
<p><font face="Georgia" color="#000000" size="4">C# code</font></p>
<pre class="brush: cpp;">

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HuluSilverLight
{
	public partial class hulu_player : UserControl
	{
		public hulu_player()
		{
			InitializeComponent();
		}

		private void pauseVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Pause();
		}

		private void playVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Play();
		}

	}
}
</pre>
<p><script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &#038;&#038; sender != 0) {
              appSource = sender.getHost().Source;
            }</p>
<p>            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;</p>
<p>            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }</p>
<p>            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;</p>
<p>            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";</p>
<p>            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }</p>
<p>            throw new Error(errMsg);
        }
    </script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Loading external video into your Hulu inspired Silverlight video player</title>
		<link>http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/</link>
		<comments>http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 12:47:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mediaelement]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://paulyanez.com/interactive/?p=515</guid>
		<description><![CDATA[This is part 2 in our series of building a Hulu inspired video player. This tutorial may well be the most important in the process of building a Silverlight video player.
In our previous example &#8220;Building a Play-Pause control for a Hulu inspired SilverLight video player&#8221; the video was included within the Silverlight file. This caused [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 2 in our series of building a Hulu inspired video player. This tutorial may well be the most important in the process of building a Silverlight video player.<span id="more-515"></span></p>
<p>In our previous example <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/">&#8220;Building a Play-Pause control for a Hulu inspired SilverLight video player&#8221;</a> the video was included within the Silverlight file. This caused a very bad user experience because the user had to wait to load the entire video before the file was shown.</p>
<p>By setting the video source to be remote, the Silverlight file is now 14k as compared to 6,700k. Now, the Silverlight file which simply contains a MediaElement is loaded almost instantaneously and the video plays as it loads.</p>
<p>View all parts of the tutorial<br />
Part 1 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/">Building a Play-Pause control</a><br />
Part 2 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/">Loading external video</a><br />
Part 3 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Progress Bar</a><br />
Part 4 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Download Progress Bar</a><br />
Part 5 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-control-for-your-hulu-inspired-silverlight-video-player/">Building a Volume Control</a><br />
Part 6 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-the-time-display-for-your-hulu-inspired-silverlight-video-player/">Building the Time Display</a><br />
Part 7 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-slider-for-your-hulu-inspired-silverlight-video-player/">Volume Slider control</a><br />
Part 8 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-start-playing-button-for-your-hulu-inspired-silverlight-video-player/">Start playing button</a></p>
<p><font face="Georgia" color="#000000" size="4">You can play and pause the video</font></p>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="276"><param name="source" value="http://www.paulyanez.com/interactive/blog/LoadExternalVideo/externalvideo.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40624.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/></p>
<p>		  </a><br />
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</p></form>
<p><font face="Georgia" color="#000000" size="4">XAML code</font></p>
<pre class="brush: xml;">

&lt;UserControl
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; xmlns:local=&quot;clr-namespace:HuluSilverLight&quot;
	x:Class=&quot;HuluSilverLight.MainPage&quot;
	Width=&quot;640&quot; Height=&quot;276&quot; mc:Ignorable=&quot;d&quot;&gt;
	&lt;Grid x:Name=&quot;LayoutRoot&quot; Margin=&quot;0,0,0,201&quot;&gt;
		&lt;MediaElement x:Name=&quot;mp&quot; Margin=&quot;0,-42,0,-240&quot; Source=&quot;http://www.paulyanez.com/interactive/blog/HD/darkknight.wmv&quot; /&gt;
		&lt;local:hulu_player Height=&quot;32&quot; Margin=&quot;0,0,0,-199&quot; VerticalAlignment=&quot;Bottom&quot;/&gt;
	&lt;/Grid&gt;
&lt;/UserControl&gt;
</pre>
<p><font face="Georgia" color="#000000" size="4">C# code</font></p>
<pre class="brush: cpp;">

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HuluSilverLight
{
	public partial class hulu_player : UserControl
	{
		public hulu_player()
		{
			InitializeComponent();
		}

		private void pauseVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Pause();
		}

		private void playVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Play();
		}

	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Play-Pause control for a Hulu inspired SilverLight video player</title>
		<link>http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/</link>
		<comments>http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 05:26:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hulu]]></category>
		<category><![CDATA[mediaelement]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[togglebutton]]></category>
		<category><![CDATA[video player]]></category>

		<guid isPermaLink="false">http://paulyanez.com/interactive/?p=491</guid>
		<description><![CDATA[The following example is the Part 1 in a series of tutorials demonstrating how to build a Hulu inspired video player in Silverlight 3. This tutorial shows how to create a play-pause button control utilizing the ToggleButton control.  
1- Place a ToggleButton on the stage
2- Right click and select &#8220;Edit Template / Edit a [...]]]></description>
			<content:encoded><![CDATA[<p>The following example is the Part 1 in a series of tutorials demonstrating how to build a Hulu inspired video player in Silverlight 3. This tutorial shows how to create a play-pause button control utilizing the ToggleButton control.  <span id="more-491"></span></p>
<p>1- Place a ToggleButton on the stage<br />
2- Right click and select &#8220;Edit Template / Edit a copy&#8221;<br />
3- Name your control<br />
4- Delete everything in the component &#8211; FocusVisualElement, DisabledVisualElement, contentPresenter and the Background. Do not delete the top level Grid.<br />
5- In the states panel add designs for the Normal, MouseOver and Pressed states.<br />
6- Add the Pause icon to the Unchecked CheckStates and the Play icon to the Checked CheckState.<br />
7- Add a MediaElement control and set it&#8217;s source.<br />
8- On your custom control add the code to pause and play the video on the Checked and UnChecked events.</p>
<p>View all parts of the tutorial<br />
Part 1 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/">Building a Play-Pause control</a><br />
Part 2 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/loading-external-video-into-your-hulu-inspired-silverlight-video-player/">Loading external video</a><br />
Part 3 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Progress Bar</a><br />
Part 4 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/11/building-a-download-progress-bar-for-your-hulu-inspired-silverlight-video-player/">Building a Download Progress Bar</a><br />
Part 5 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-control-for-your-hulu-inspired-silverlight-video-player/">Building a Volume Control</a><br />
Part 6 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-the-time-display-for-your-hulu-inspired-silverlight-video-player/">Building the Time Display</a><br />
Part 7 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-volume-slider-for-your-hulu-inspired-silverlight-video-player/">Volume Slider control</a><br />
Part 8 &#8211; <a href="http://paulyanez.com/interactive/index.php/2009/12/building-a-start-playing-button-for-your-hulu-inspired-silverlight-video-player/">Start playing button</a></p>
<p><font face="Georgia" color="#000000" size="4">You can play and pause the video</font></p>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="276"><param name="source" value="http://www.paulyanez.com/interactive/blog/PlayPause/play-pause.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40624.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/></p>
<p>		  </a><br />
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</p></form>
<p><font face="Georgia" color="#000000" size="4">XAML code</font></p>
<pre class="brush: xml;">

&lt;UserControl
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; xmlns:local=&quot;clr-namespace:HuluSilverLight&quot;
	x:Class=&quot;HuluSilverLight.MainPage&quot;
	Width=&quot;640&quot; Height=&quot;276&quot; mc:Ignorable=&quot;d&quot;&gt;
	&lt;Grid x:Name=&quot;LayoutRoot&quot; Margin=&quot;0,0,0,201&quot;&gt;
		&lt;MediaElement x:Name=&quot;mp&quot; Margin=&quot;0,-42,0,-240&quot; Source=&quot;IronMan.wmv&quot; /&gt;
		&lt;local:hulu_player Height=&quot;32&quot; Margin=&quot;0,0,0,-199&quot; VerticalAlignment=&quot;Bottom&quot;/&gt;
	&lt;/Grid&gt;
&lt;/UserControl&gt;
</pre>
<p><font face="Georgia" color="#000000" size="4">C# code</font></p>
<pre class="brush: cpp;">

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HuluSilverLight
{
	public partial class hulu_player : UserControl
	{
		public hulu_player()
		{
			InitializeComponent();
		}

		private void pauseVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Pause();
		}

		private void playVideo(object sender, System.Windows.RoutedEventArgs e)
		{
			(Application.Current.RootVisual as MainPage).mp.Play();
		}

	}
}
</pre>
<p><script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &#038;&#038; sender != 0) {
              appSource = sender.getHost().Source;
            }</p>
<p>            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;</p>
<p>            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }</p>
<p>            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;</p>
<p>            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";</p>
<p>            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }</p>
<p>            throw new Error(errMsg);
        }
    </script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulyanez.com/interactive/index.php/2009/11/building-a-play-pause-control-for-a-hulu-inspired-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically creating thumbnails with WriteableBitmap and DispatcherTimer in Silverlight 3</title>
		<link>http://paulyanez.com/interactive/index.php/2009/11/dynamically-creating-thumbnails-of-video-frames-with-writeablebitmap-in-silverlight-3/</link>
		<comments>http://paulyanez.com/interactive/index.php/2009/11/dynamically-creating-thumbnails-of-video-frames-with-writeablebitmap-in-silverlight-3/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 20:43:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[dispatchertimer]]></category>
		<category><![CDATA[mediaelement]]></category>
		<category><![CDATA[mediaended]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[writeablebitmap]]></category>

		<guid isPermaLink="false">http://paulyanez.com/interactive/?p=479</guid>
		<description><![CDATA[In the previous example &#8220;Creating thumbnails of video frames with WriteableBitmap in Microsoft Expression Blend 3&#8243; the user was able to create thumbnails by clicking on the video display.
The following example shows how thumbnails could be dynamically created by using DispatcherTimer thereby eliminating the need to click. 
To stop the timer from firing, I simply [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous example <a href="http://paulyanez.com/interactive/index.php/2009/11/creating-thumbnails-of-video-frames-with-writeablebitmap-in-microsoft-expression-blend/">&#8220;Creating thumbnails of video frames with WriteableBitmap in Microsoft Expression Blend 3&#8243;</a> the user was able to create thumbnails by clicking on the video display.</p>
<p>The following example shows how thumbnails could be dynamically created by using DispatcherTimer thereby eliminating the need to click. <span id="more-479"></span></p>
<p>To stop the timer from firing, I simply hooked into the MediaElement mediaEnded event. </p>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="600" height="600"><param name="source" value="http://www.paulyanez.com/interactive/blog/Timer/ImageSnapshotTimer.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40624.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/></p>
<p>		  </a><br />
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</p></form>
<p><font face="Georgia" color="#000000" size="4">XAML code</font></p>
<pre class="brush: xml;">

&lt;UserControl
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
	x:Class=&quot;ImageSnapshot.MainPage&quot;
	Width=&quot;605&quot; Height=&quot;610&quot; mc:Ignorable=&quot;d&quot; Background=&quot;Black&quot;&gt;

	&lt;StackPanel  Orientation=&quot;Vertical&quot; HorizontalAlignment=&quot;Stretch&quot; Margin=&quot;10&quot;&gt;
		&lt;MediaElement x:Name=&quot;myMediaElement&quot; Source=&quot;/Movie.wmv&quot; Height=&quot;416&quot; d:LayoutOverrides=&quot;HorizontalMargin&quot; Cursor=&quot;Hand&quot; MediaEnded=&quot;stopTimer&quot;/&gt;
		&lt;ScrollViewer x:Name=&quot;scroller&quot; HorizontalScrollBarVisibility=&quot;Auto&quot; VerticalScrollBarVisibility=&quot;Hidden&quot; Height=&quot;160&quot; BorderBrush=&quot;{x:Null}&quot; Margin=&quot;8,0&quot;&gt;
			&lt;StackPanel x:Name=&quot;thumbs&quot; Orientation=&quot;Horizontal&quot; Margin=&quot;0,5,0,10&quot;  /&gt;
		&lt;/ScrollViewer&gt;
	&lt;/StackPanel&gt;
&lt;/UserControl&gt;
</pre>
<p><font face="Georgia" color="#000000" size="4">C# code</font></p>
<pre class="brush: cpp;">

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace ImageSnapshot
{
	public partial class MainPage : UserControl
	{
		System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();

		public MainPage()
		{
			InitializeComponent();

            myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            myDispatcherTimer.Tick += new EventHandler(takeSnapShot);
            myDispatcherTimer.Start();
		}
		private void takeSnapShot(object o, EventArgs sender)
		{
			WriteableBitmap snapShot = new WriteableBitmap(myMediaElement, null);

			Image image = new Image();
			image.Height = 89;
			image.Margin = new Thickness(10);
			image.Source = snapShot;

			thumbs.Children.Add(image);
			scroller.UpdateLayout();
			double scrollPos = thumbs.ActualWidth;
			scroller.ScrollToHorizontalOffset(scrollPos);
		}

		private void stopTimer(object sender, System.Windows.RoutedEventArgs e)
		{
			myDispatcherTimer.Stop();
		}
	}
}
</pre>
<p> <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &#038;&#038; sender != 0) {
              appSource = sender.getHost().Source;
            }</p>
<p>            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;</p>
<p>            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }</p>
<p>            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;</p>
<p>            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";</p>
<p>            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }</p>
<p>            throw new Error(errMsg);
        }
    </script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulyanez.com/interactive/index.php/2009/11/dynamically-creating-thumbnails-of-video-frames-with-writeablebitmap-in-silverlight-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

