<?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>Corey Schuman &#187; timer</title>
	<atom:link href="http://www.85turns.com/tag/timer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.85turns.com</link>
	<description>Silverlight Consultant</description>
	<lastBuildDate>Tue, 26 Apr 2011 20:57:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Create a video player in Silverlight 2 &#8211; Part 2</title>
		<link>http://www.85turns.com/2008/04/15/create-a-video-player-silverlight-2-part-2/</link>
		<comments>http://www.85turns.com/2008/04/15/create-a-video-player-silverlight-2-part-2/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 02:15:45 +0000</pubDate>
		<dc:creator>Corey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[buffering]]></category>
		<category><![CDATA[MediaElement]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[volume]]></category>

		<guid isPermaLink="false">http://simplesilverlight.wordpress.com/?p=56</guid>
		<description><![CDATA[In part 1 we covered setting up a very basic video player. In part 2 we will add Scrubbing the video wiring up volume, and muting. In future versions I will show how to display a buffer message, skin the controls, and how to work with media that&#8217;s not embedded in the xap. Scrubbing Add [...]]]></description>
			<content:encoded><![CDATA[<p>In <a title="http://simplesilverlight.wordpress.com/2008/04/02/create-a-video-player-silverlight-2-part-1/" href="http://simplesilverlight.wordpress.com/2008/04/02/create-a-video-player-silverlight-2-part-1/">part 1</a> we covered setting up a very basic video player.  In part 2 we will add</p>
<ul>
<li>Scrubbing the video</li>
<li>wiring up volume,</li>
<li>and muting.</li>
</ul>
<p>In future versions I will show how to display a buffer message, skin the controls, and how to work with media that&#8217;s not embedded in the xap.</p>
<ol>
<li><strong>Scrubbing</strong>
<ul>
<li>Add a MouseLeftButtonDown and MouseLeftButtonUp events for the slider in the constructor.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderevents.png"><img class="alignnone size-full wp-image-58" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderevents.png?w=480" alt="Register MouseLeftButtonDown and MouseLeftButtonUp events for the slider" /></a><a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderevents.png"><br />
</a></li>
<li>Add a property to lock the scrubber while the mouse button is down.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-isscrubberlocked1.png"><img class="alignnone size-medium wp-image-74" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-isscrubberlocked1.png" alt="" /></a></li>
<li>In the MouseLeftButtonDown event, set the scrubber lock to true.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderleftbuttondown1.png"><img class="alignnone size-medium wp-image-73" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderleftbuttondown1.png?w=480" alt="" /></a></li>
<li>In the MouseLeftButtonUp event, release the lock on the scrubber and update the position of the video.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderleftbuttonup1.png"><img class="alignnone size-medium wp-image-72" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-sliderleftbuttonup1.png?w=480" alt="" /></a></li>
<li>Finally in the Tick event of the timer, prevent updating the position of the slider while the scrubber is locked.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-timertick1.png"><img class="alignnone size-medium wp-image-71" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-timertick1.png?w=480" alt="" /></a></li>
</ul>
</li>
<li><strong>Volume</strong>
<ul>
<li>XAML.  It important to set the Min to 0 and the Max to 1.  The MediaElements volume ranges from 0 to 1.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-xaml-slidervolume.png"><img class="alignnone size-full wp-image-70" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-xaml-slidervolume.png" alt="" /></a></li>
<li>Register the ValueChanged event in the constructor for the slider.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-volumevaluechangedreg.png"><img class="alignnone size-full wp-image-75" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-volumevaluechangedreg.png?w=480" alt="" /></a></li>
<li>Set the video&#8217;s volume to the value in the ValueChanged event.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-volumevaluechanged.png"><img class="alignnone size-full wp-image-69" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-volumevaluechanged.png?w=480" alt="" /></a></li>
<li>Set the initial position of the slider to the video&#8217;s volume.  You can either do this in the CurrentStateChanged event or the MediaOpened event of the MediaElement.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-setslidervolume.png"><img class="alignnone size-full wp-image-68" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-setslidervolume.png" alt="" /></a></li>
</ul>
</li>
<li><strong>Mute button</strong>
<ul>
<li>XAML, add a ToggleButton<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-xaml-togglemute.png"><img class="alignnone size-full wp-image-67" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-xaml-togglemute.png?w=480" alt="" /></a></li>
<li>Register the Checked and UnChecked events in the constuctor for the mute button.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-btnevents.png"><img class="alignnone size-medium wp-image-66" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-btnevents.png?w=480" alt="" /><br />
</a></li>
<li>Add a variable to store the previous volume.<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-previousvolume.png"><img class="alignnone size-full wp-image-65" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-previousvolume.png" alt="" /><br />
</a></li>
<li>Checked event<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-mutechecked.png"><img class="alignnone size-full wp-image-64" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-mutechecked.png" alt="" /><br />
</a></li>
<li>UnChecked event<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-muteunchecked.png"><img class="alignnone size-full wp-image-63" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-cs-muteunchecked.png" alt="" /></a></li>
</ul>
</li>
<li>Resulting player<br />
<a href="http://simplesilverlight.files.wordpress.com/2008/04/part2-final.png"><img class="alignnone size-full wp-image-76" src="http://simplesilverlight.files.wordpress.com/2008/04/part2-final.png?w=480" alt="" /></a></li>
</ol>
<p>Files:<br />
Instead of the whole project (because the video is embedded in the project), here are the two important pieces of this project</p>
<p><a title="http://www.coreyschuman.com/Silverlight/Blogfiles/videoplayer/Page.xaml.txt" href="http://www.coreyschuman.com/Silverlight/Blogfiles/videoplayer/Page.xaml.txt">XAML</a></p>
<p><a title="http://www.coreyschuman.com/Silverlight/Blogfiles/videoplayer/Page.xaml.cs.txt" href="http://www.coreyschuman.com/Silverlight/Blogfiles/videoplayer/Page.xaml.cs.txt">C#</a></p>
<h2><span style="color:#800000;">UPDATE</span></h2>
<p>If you are having problems with the Slider not recoginzing MouseLeftButtonUp or MouseLeftButtonDown events, check out the <a href="http://simplesilverlight.wordpress.com/2008/09/09/video-slider-control/"><strong>VideoSlider</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.85turns.com/2008/04/15/create-a-video-player-silverlight-2-part-2/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

