<?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>Silverlight &#124; WPF &#124; Microsoft.Net &#187; Video Player</title>
	<atom:link href="http://joel.neubeck.net/tag/video-player/feed/" rel="self" type="application/rss+xml" />
	<link>http://joel.neubeck.net</link>
	<description>Simplifing structure without changing results</description>
	<lastBuildDate>Wed, 26 May 2010 18:43:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Silverlight Screencast Site</title>
		<link>http://joel.neubeck.net/2009/03/silverlight-screencast-site/</link>
		<comments>http://joel.neubeck.net/2009/03/silverlight-screencast-site/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 16:52:51 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Industry]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Screencast]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=359</guid>
		<description><![CDATA[When I think back to where Silverlight was just a year ago, it is so exciting to see how far it has come and how much the community has embraced it. Recently I stumbled upon a nice Silverlight podcast called Sparkling client. Sparkling Client is a podcast by Eric Mork about Silverlight and other RIA [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sparklingclient.com"><img class="alignleft size-full wp-image-361" title="sparklingclint" src="http://joel.neubeck.net/wp-content/uploads/2009/03/sparklingclint.png" alt="sparklingclint" width="250" height="47" /></a>When I think back to where Silverlight was just a year ago, it is so exciting to see how far it has come and how much the community has embraced it.  Recently I stumbled upon a nice Silverlight podcast called <a href="http://www.sparklingclient.com/">Sparkling client</a>.  Sparkling Client is a podcast by Eric Mork about Silverlight and other RIA technologies.   This week they talk about a new community <a href=" http://development-guides.silverbaylabs.org/">screencast site</a> they are working on that will give the community a new place to learn about RIA technology.   I was excited to see that the team at Silver Bay Labs was able to leverage some of the work I did on the <a href="http://codeplex.com/sl2videoplayer">Silverlight Video Player</a> located on CodePlex.  Good luck to the new site!</p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2009/03/silverlight-screencast-site/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Silverlight Video Player updated to display external bookmarks</title>
		<link>http://joel.neubeck.net/2008/08/sl2videoplayer-external-bookmark/</link>
		<comments>http://joel.neubeck.net/2008/08/sl2videoplayer-external-bookmark/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 17:17:14 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Bookmark]]></category>
		<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[ScriptableMember]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/2008/08/sl2videoplayer-external-bookmark/</guid>
		<description><![CDATA[Last week someone requested a new feature to the Silverlight 2 Video player on CodePlex that would allow users to create an external list of &#8220;bookmarks&#8221;, that would link to a specific marker or moment in playback.  The idea would be to have a series of links outside of Silverlight, that once clicked,playback would jump [...]]]></description>
			<content:encoded><![CDATA[<p>Last week someone requested a new feature to the <a href="http://www.codeplex.com/sl2videoplayer/" target="_blank">Silverlight 2 Video player on CodePlex</a> that would allow users to create an external list of &#8220;bookmarks&#8221;, that would link to a specific marker or moment in playback.  The idea would be to have a series of links outside of Silverlight, that once clicked,playback would jump to that moment in the video.</p>
<p>When I originally created marker support I had given this some thought and was just waiting for the opportunity to add this feature.  I am excited someone really wants it.  Back in July I created a post called <a href="http://joel.neubeck.net/2008/07/communicating-between-sl2-objects/" target="_blank">Communicating between two Silverlight objects on a single page</a>. In this post I demonstrate how one can use a <strong>[ScriptableMember]</strong> to expose a method to JavaScript. To add this feature to the Video Player I can use this technique.</p>
<p>The first step was to create a method in my mediaControls control, which would allow a time (TimeSpan) to be passed during playback.  This call will jump the slider to that position in time and begin or continue playback.</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="sl2video_externalLink2" src="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink2-thumb.png" border="0" alt="sl2video_externalLink2" width="457" height="221" align="left" /> <br style="clear: both" /><a href="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="sl2video_externalLink" src="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink-thumb.png" border="0" alt="sl2video_externalLink" width="383" height="125" align="left" /></a>Once we have a method in mediaControl we can expose a scriptable method in Page.xaml. This method can be called from any page hosting out Silverlight XAP.     <br style="clear: both" /></p>
<p>To demonstrate how to use this method I created a sample html page that presents a list of bookmarks that target the video player.  Each link calls a JavaScript method, that in turn calls my [ScritableMember]</p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink4.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="sl2video_externalLink4" src="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink4-thumb.png" border="0" alt="sl2video_externalLink4" width="499" height="72" align="left" /></a> <br style="clear: both" /><a href="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink3.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="sl2video_externalLink3" src="http://joel.neubeck.net/wp-content/uploads/2008/08/sl2video-externallink3-thumb.png" border="0" alt="sl2video_externalLink3" width="531" height="91" align="left" /></a> <br style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/08/sl2videoplayer-external-bookmark/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Silverlight Video Player updated to display Closed Captioning</title>
		<link>http://joel.neubeck.net/2008/07/sl2videoplayer-closed-captioning/</link>
		<comments>http://joel.neubeck.net/2008/07/sl2videoplayer-closed-captioning/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 15:02:47 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Closed Captioning]]></category>
		<category><![CDATA[ToggleButton]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=205</guid>
		<description><![CDATA[Yesterday I completed the first version of Closed Captioning support for the Silverlight 2 Video Player on CodePlex.  It definitely in an alpha phase, but with some polish it should be reliable and more usable.  Here is an image of how the captions are being displayed. In this first version I made a decision to [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I completed the first version of Closed Captioning support for the <a title="SL2 Video Player" href="http://www.codeplex.com/sl2videoplayer/" target="_blank">Silverlight 2 Video Player</a> on CodePlex.  It definitely in an alpha phase, but with some polish it should be reliable and more usable.  Here is an image of how the captions are being displayed.</p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/video_cc.png"><img class="aligncenter size-full wp-image-206" title="video_cc" src="http://joel.neubeck.net/wp-content/uploads/2008/07/video_cc.png" alt="" width="500" height="248" /></a><br style="clear:both"/>In this first version I made a decision to display closed captioning when the volume is muted, but with the right visualization we should be able to find a nice place for a ToggleButton.  Here is a list of a few other things I did to the project.</p>
<ul>
<li>Updated Xml parsing to support markers with multiple types (Marker, CC, etc)</li>
<li>Converted speaker button control to ToggleButton to display a different visualization when the player is muted.</li>
<li>Linked volumeSlider to speaker button so slider drops to zero on mute and back to previous volume when mute is turned off.</li>
<li>Added a new event from mediaControl that is fired when the volume is changed.  This allows the player to control closed captioning display and not the media controller.</li>
<li>Wrote closedCaptioning UserControl that visualizes the scrolling captions.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/07/sl2videoplayer-closed-captioning/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Asynchronous loading of TimelineMarkers for Silverlight Video Player</title>
		<link>http://joel.neubeck.net/2008/07/asynchronous-loading-of-timelinemarkers-for-silverlight-video-player/</link>
		<comments>http://joel.neubeck.net/2008/07/asynchronous-loading-of-timelinemarkers-for-silverlight-video-player/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 20:50:05 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[Dispatcher.BeginInvoke]]></category>
		<category><![CDATA[TimeLineMarker]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/2008/07/asynchronous-loading-of-timelinemarkers-for-silverlight-video-player/</guid>
		<description><![CDATA[As part of the ongoing evolution of our Open Source Silverlight Video Player on CodePlex, I added the ability to asynchronously load a set of TimeLineMarkers from an XML document.&#160; The goal was to allow users a choice between encoding there video with markers or defining those markers in an external xml file.&#160; What I [...]]]></description>
			<content:encoded><![CDATA[<p>As part of the ongoing evolution of our Open Source <a href="http://www.codeplex.com/sl2videoplayer/" target="_blank">Silverlight Video Player on CodePlex</a>, I added the ability to asynchronously load a set of <strong>TimeLineMarkers</strong> from an XML document.&#160; The goal was to allow users a choice between encoding there video with markers or defining those markers in an external xml file.&#160; What I thought would be a pretty trivial task, proved to be an interesting challenge. Here is a snapshot of the Xml format.</p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/marker-1.png"><img title="marker_1" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="marker_1" src="http://joel.neubeck.net/wp-content/uploads/2008/07/marker-1-thumb.png" width="473" align="left" border="0" /></a> </p>
<p>  <br style="clear: both" />
<p>The first step in implementing this functionality was to download the marker Xml.&#160; In the event that this marker file was quite large in size I decided to make the download asynchronous.&#160; Downloading a file asynchronously required that the path to the file is absolute.&#160; Since I have no real control over my <strong>initParams</strong> I decided to support both an absolute or relative Uri.&#160; In the event that the path to the Xml document is relative, I make a reasonable assumption that it is located in the same location as the XAP.&#160; As a result ,I can define my Uri with “<strong>Host.Source</strong>” as the baseUri of the Xml document.&#160; To Download the file, I simply make a <strong>WebRequest</strong> and define an <strong>AsyncCallback</strong> to be fired when the file has completed downloading.&#160; </p>
<p><strong>Threading Considerations</strong></p>
<p>In Silverlight 2 Beta 2 there was a significant change in the concurrency model used for asynchronous communications.&#160; In Beta 1 these type of requests returned on the UI thread.&#160; In Beta 2, when you choose to use the BeginGetResponse of the WebRequest you are telling Silverlight to use a worker thread that comes from a thread pool.&#160; As a result, you can NOT update any user interface elements on the UI thread.&#160; Initially I thought I would be able to use “Application.Current.RootVisual.Dispatcher” as a way to execute a delegate on the UIThread.&#160; Unfortunately this throws a Cross Thread exception.&#160; After explored a few options I realized that I could simply call <strong>Dispatcher.BeginInvoke(MyMethod)</strong> from within my AsyncCallback.&#160; here is what that looked like.</p>

<div class="wp_syntax"><div class="code"><pre class="c-sharp" style="font-family:monospace;">void OpenStreamCompleted(IAsyncResult ar)
{
    HttpWebRequest request = ar.AsyncState as HttpWebRequest;
    WebResponse response = request.EndGetResponse(ar);
&nbsp;
    // Read the response into a Stream object.
    Stream responseStream = response.GetResponseStream();
&nbsp;
    // Create a new StreamReader instance using the specified Stream object.
    using (StreamReader streamreader = new StreamReader(responseStream))
    {
        XElement document = XElement.Load(streamreader); 
        _externalMarkerData = (from el in document.Elements() select GetMarkerData(el)).ToList();
    }
    Dispatcher.BeginInvoke(ProcessParsedMarkerCollection);
}</pre></div></div>

<p>As you can see above, once I have the Xml downloaded I parse it from Xml into a collection. For this I thought it would be cool to use Linq for XML.&#160; I am always amazed at how few a lines of code I need to write to parse an Xml document with Linq.&#160; The end product of the parse is a List&lt;&gt; containing a very simple custom object called “MarkerData”.&#160; If I had chosen to move this parsing back to the UIThread I could have just created a collection of TimelineMarkers, but I thought there was no harm in having my own object to expand over time.</p>
<p>To get the latest source visit the project at <a title="http://www.codeplex.com/sl2videoplayer" href="http://www.codeplex.com/sl2videoplayer">http://www.codeplex.com/sl2videoplayer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/07/asynchronous-loading-of-timelinemarkers-for-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Silverlight 2 Video Player pushed to CodePlex</title>
		<link>http://joel.neubeck.net/2008/06/silverlight-2-video-player-pushed-to-codeplex/</link>
		<comments>http://joel.neubeck.net/2008/06/silverlight-2-video-player-pushed-to-codeplex/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 18:26:03 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Tim Heuer]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=166</guid>
		<description><![CDATA[Yesterday Tim Heuer made a great suggestion that we submit our collaboration on a  Silverlight 2 Video Player as Open Source to CodePlex. You can now find the latest source at http://www.codeplex.com/sl2videoplayer.  As we find any &#8220;undocumented features&#8221; or add new and exciting ehancments we will push these up to CodePlex.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codeplex.com/sl2videoplayer"><img class="alignleft size-full wp-image-167" title="codeplex-logo_thumb" src="http://joel.neubeck.net/wp-content/uploads/2008/06/codeplex-logo_thumb.jpg" alt="" width="235" height="92" /></a>Yesterday Tim Heuer made a great suggestion that we submit our collaboration on a  Silverlight 2 Video Player as Open Source to CodePlex.  You can now find the latest source at <a title="http://www.codeplex.com/sl2videoplayer" href="http://www.codeplex.com/sl2videoplayer">http://www.codeplex.com/sl2videoplayer</a>.  As we find any &#8220;undocumented features&#8221; or add new and exciting ehancments we will push these up to CodePlex.</p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/06/silverlight-2-video-player-pushed-to-codeplex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight 2 &#8211; Media Player with Marker support</title>
		<link>http://joel.neubeck.net/2008/06/sl2b2-media-player-markers/</link>
		<comments>http://joel.neubeck.net/2008/06/sl2b2-media-player-markers/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 17:10:32 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MediaElement]]></category>
		<category><![CDATA[Slider]]></category>
		<category><![CDATA[Tim Heuer]]></category>
		<category><![CDATA[TimeLineMarker]]></category>
		<category><![CDATA[Video Player]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/2008/06/sl2b2-media-player-markers/</guid>
		<description><![CDATA[Please note: This sample was made into a Code Plex project and is maintained there. Please download all source from http://www.codeplex.com/sl2videoplayer/ Back in April I created a very simple Video Player in Silverlight 2 Beta 1 which Tim Heuer took to a whole new level. In his first pass he added dynamic resizing and initParams [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Please note</strong>: This sample was made into a Code Plex project and is maintained there.  Please download all source from <a href="http://www.codeplex.com/sl2videoplayer/">http://www.codeplex.com/sl2videoplayer/</a></p></blockquote>
<p>Back in April I created a very simple Video Player in Silverlight 2 Beta 1 which <a href="http://timheuer.com" target="_blank">Tim Heuer</a> took to a whole new level. In his first pass he added dynamic resizing and initParams to load the video source. Then back a few weeks ago Tim brought it up to speed for Beta 2 and integrated the &quot;VisualStateManager&quot; to get the ToggleButton to function correctly. I love how it turned out. </p>
<p>One thing that I really wanted to include in my first version was control for TimelineMarkers. Unfortunately in Beta 1 I had some issues with dynamic markers, and decided to hold off until Beta 2 was released. Microsoft Expression Encoder 2 is a great tool and makes it very easy to insert markers that fire events during video playback. Markers are very simple, they define a TimeSpan of when to fire the &quot;MarkerReached&quot; event, and define some text that describes the marker.&#160;&#160; In my example I will use this text as the copy for my Marker Popup.&#160; Here is how I chose to visualize my markers in the video player. </p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c2.png"><img title="videoplayer_c2" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="114" alt="videoplayer_c2" src="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c2-thumb.png" width="292" align="left" border="0" /></a> </p>
<p>To achieve this effect, I created a custom UserControl called &quot;Marker.xaml&quot;. This control contains a single animation which will fade in the text, and fade it out again after a predefined amount of time.&#160; The control is comprised of a TextBlock and a “Arrow” path that can be moved left and right within the second row of a Grid control.&#160; This gives me the ability to control where the Arrow visualizes in relation to my Timeline Slider control.</p>
<p>Based on the number of markers encoded in the video an equal number of markers will be placed in the “MediaControl”.&#160; There position on the slider time line is determined by calculating the following: </p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c31.png"><img title="videoplayer_c3" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="91" alt="videoplayer_c3" src="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c3-thumb1.png" width="500" align="left" border="0" /></a> </p>
<p>   <br style="clear: both" />The position is not absolute, but close enough to where the “Thumb” in the slider control will exist at that moment the marker should popup.&#160;&#160; Once I have placed a marker into the appropriate Grid on my MediaControl I store it in a generic Dictionary keyed off of the time it should be displayed. This allows me to very quickly find the UserControl when the Media.MarkerReached event fires or the player goes into fullscreen mode.&#160;&#160; In the event that the user wants to play the video in fullscreen, I must reposition my markers relative to the new ActualWidth of the&#160; sliderTimeline.&#160; </p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c4.png"><img title="videoplayer_c4" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="117" alt="videoplayer_c4" src="http://joel.neubeck.net/wp-content/uploads/2008/06/videoplayer-c4-thumb.png" width="500" align="left" border="0" /></a> </p>
<p>  <br style="clear: both" />
<p>Here is how it all turned out.&#160; </p>
<p><iframe src="/wp-content/uploads/2008/06/VideoPlayerMarkers/default.html" width="500" height="240"></iframe></p>
<p>Code: <a onclick="javascript: pageTracker._trackPageview(&#39;/code/VideoPlayerMarkers.zip&#39;);" href="http://www.codeplex.com/sl2videoplayer/">Code Plex</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/06/sl2b2-media-player-markers/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Silverlight how-to: Video Player</title>
		<link>http://joel.neubeck.net/2008/04/silverlight2-how-to-video-player/</link>
		<comments>http://joel.neubeck.net/2008/04/silverlight2-how-to-video-player/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 17:48:44 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ControlTemplate]]></category>
		<category><![CDATA[MediaElement]]></category>
		<category><![CDATA[Slider]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[ToggleButton]]></category>
		<category><![CDATA[Video Player]]></category>
		<category><![CDATA[Xaml]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=129</guid>
		<description><![CDATA[Please note: This sample was made into a Code Plex project and is maintained there. Please download all source from http://www.codeplex.com/sl2videoplayer/ In my ongoing quest to work with Silverlight 2 I embarked on building my own video player using the standard MediaElement and a few of the new System Controls (ToggleButon, Slider and Button). My [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Please note</strong>: This sample was made into a Code Plex project and is maintained there.  Please download all source from <a href="http://www.codeplex.com/sl2videoplayer/">http://www.codeplex.com/sl2videoplayer/</a></p></blockquote>
<p>In my ongoing quest to work with Silverlight 2 I embarked on building my own video player using the standard MediaElement and a few of the new System Controls (ToggleButon, Slider and Button). My goal was to build a video player using no custom user controls, but instead leveraging controls styles and templates.&#160; Here is the Video Player I ended up developing.</p>
<p><iframe src="/wp-content/uploads/2008/04/VideoPlayer/default.html" width="480" height="360"></iframe></p>
<p>As you can see from my example, I was able to get a pretty clean look and feel with minimal artistic skills required.&#160;&#160; The way my player is constructed, I have opted to encapsulate the controls for playing video into its own UserControl.&#160; This allowed me to have a single place responsible for managing playback while allowing the main xaml page to control how the MediaElement is presented.&#160; To give the controller access to a specific MediaElement, I pass it to my controller via a public property.</p>
<p>Most of the customization techniques I used are pretty well documented on MSDN.&#160; Nonetheless, mastering controls styles was definitely a challenge. For those unfamiliar with control styles, here is an example of the xaml I used to &quot;skin&quot; my mute button.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style</span> <span style="color: #000066;">x:key</span>=<span style="color: #ff0000;">&quot;speakerStyle&quot;</span> <span style="color: #000066;">targettype</span>=<span style="color: #ff0000;">&quot;Button&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setter</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;Template&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setter.value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;controltemplate</span> <span style="color: #000066;">targettype</span>=<span style="color: #ff0000;">&quot;Button&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;grid</span> <span style="color: #000066;">x:name</span>=<span style="color: #ff0000;">&quot;RootElement&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">stretch</span>=<span style="color: #ff0000;">&quot;Fill&quot;</span> <span style="color: #000066;">fill</span>=<span style="color: #ff0000;">&quot;#FFFFFFFF&quot;</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;F1 M 23.1457,</span>
<span style="color: #009900;">            26.5056L 23.1457,33.8944l 25.7913,33.8944l 28.8235,37.4722l </span>
<span style="color: #009900;">            30.5346,37.4722l 30.5665,23.0833l 28.8995,23.0833l 25.8679,</span>
<span style="color: #009900;">            26.5056l 23.1457,26.5056 z &quot;</span> <span style="color: #000066;">Width</span>=<span style="color: #ff0000;">&quot;7.42080116271973&quot;</span> </span>
<span style="color: #009900;">            <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14.3889999389648&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/controltemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/setter.value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/setter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This is about as simple a skin as one can get. If I were doing this for a real client I would have certainly choose to give my button multiple states (MouseOver, Down, ect) In Silverlight 2 control states are achieved by including specific named Storyboards in your ControlTemplate resource dictionary. Each control provides a different set of pre defined states. Here is a list of the states available for a ToggleButton.</p>
<ul>
<li><strong>Checked State</strong> &#8211; The normal checked state of the control. </li>
<li><strong>Indeterminate State</strong> &#8211; The normal indeterminate state of the control. </li>
<li><strong>Normal State</strong> &#8211; The normal unchecked state of the control. </li>
<li><strong>MouseOver Checked State</strong> &#8211; The state that is triggered when the mouse pointer is positioned over the checked control. </li>
<li><strong>MouseOver Indeterminate State</strong> &#8211; The state that is triggered when the mouse pointer is positioned over the indeterminate control. </li>
<li><strong>MouseOver Unchecked State</strong> &#8211; The state that is triggered when the mouse pointer is positioned over the unchecked control. </li>
<li><strong>Pressed Checked State</strong> &#8211; The state that is triggered when the checked control is pressed. </li>
<li><strong>Pressed Indeterminate State</strong> &#8211; The state that is triggered when the indeterminate control is pressed. </li>
<li><strong>Pressed Unchecked State</strong> &#8211; The state that is triggered when the unchecked control is pressed. </li>
<li><strong>Disabled Checked State</strong> &#8211; The state that is triggered when the checked control is disabled. </li>
<li><strong>Disabled Indeterminate State</strong> &#8211; The state that is triggered when the indeterminate control is disabled. </li>
<li><strong>Disabled Unchecked State</strong> &#8211; The state that is triggered when the unchecked control is disabled. </li>
</ul>
<p>In my example I use the ToggleButton to control playback of the video.&#160; Instead of creating two buttons, one for play and one for pause, I&#160; choose to use a ToggleButton to combine them into one.&#160; I display a play symbol when the video is stopped or paused, and a pause symbol when the video is playing.&#160; The ToggleButton functions just like a checkbox, clicking it once &quot;check&#8217;s&quot; it while clicking it again &quot;uncheck&#8217;s&quot; it.&#160;&#160; The following&#160; is a sample of one of the Storyboards I used in skinning my ToggleButton. This animation controls which elements are visualized when a users presses the ToggleButton in an previously checked state.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;storyboard</span> <span style="color: #000066;">x:key</span>=<span style="color: #ff0000;">&quot;Pressed Checked State&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;doubleanimation</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0:0:0.1&quot;</span> </span>
<span style="color: #009900;">     <span style="color: #000066;">storyboard.targetname</span>=<span style="color: #ff0000;">&quot;playSymbol&quot;</span> </span>
<span style="color: #009900;">     <span style="color: #000066;">storyboard.targetproperty</span>=<span style="color: #ff0000;">&quot;Opacity&quot;</span> <span style="color: #000066;">to</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;doubleanimation</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0:0:0.1&quot;</span> </span>
<span style="color: #009900;">     <span style="color: #000066;">storyboard.targetname</span>=<span style="color: #ff0000;">&quot;pauseSymbol&quot;</span> </span>
<span style="color: #009900;">     <span style="color: #000066;">storyboard.targetproperty</span>=<span style="color: #ff0000;">&quot;Opacity&quot;</span> <span style="color: #000066;">to</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;doubleanimation</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0:0:0.1&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">storyboard.targetname</span>=<span style="color: #ff0000;">&quot;buttonPressed&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">storyboard.targetproperty</span>=<span style="color: #ff0000;">&quot;Opacity&quot;</span> <span style="color: #000066;">to</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/storyboard<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>In the code above, I am ensuring that the play symbol is hidden while I show both a pause symbol and an glow image used to show the button is being pressed.</p>
<p>As for procedural code, all of the heavy lifting is done in the mediaControl.xaml.cs codebehind file.&#160; The majority of code is event handlers responding to user interactions (clicks, drags,etc) or a single DispatcherTimer monitoring progress in the video playback.&#160; My&#160; DispatcherTimer fires a tick every 50 milliseconds which update how much time has played and visualizes on a slider how much time remains.</p>
<p>Code: <a onclick="javascript: pageTracker._trackPageview(&#39;/code/VideoPlayer.zip&#39;);" href="http://www.codeplex.com/sl2videoplayer">Code Plex</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/04/silverlight2-how-to-video-player/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
