<?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; totalseconds</title>
	<atom:link href="http://paulyanez.com/interactive/index.php/tag/totalseconds/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 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>
	</channel>
</rss>

