<?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; ScriptableMember</title>
	<atom:link href="http://joel.neubeck.net/tag/scriptablemember/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 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>Communicating between two Silverlight objects on a single page</title>
		<link>http://joel.neubeck.net/2008/07/communicating-between-sl2-objects/</link>
		<comments>http://joel.neubeck.net/2008/07/communicating-between-sl2-objects/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 08:35:00 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[RegisterScriptableObject]]></category>
		<category><![CDATA[ScriptableMember]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/2008/07/communicating-between-sl2-objects/</guid>
		<description><![CDATA[Not sure where I stumbled on it, but recently I watched video online where as the video was playing, a banner ad on the same page changed as the context of the video changed.&#160; I was intrigued by the potential this technique had in interactive marketing.&#160; As I was watching the video I was envisioning [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure where I stumbled on it, but recently I watched video online where as the video was playing, a banner ad on the same page changed as the context of the video changed.&#160; I was intrigued by the potential this technique had in interactive marketing.&#160; As I was watching the video I was envisioning a character picking up a can of Pepsi and at that moment a corresponding banner ad somewhere else on the page switching to an ad for Pepsi.&#160; This could be a very powerful way to create interactive calls to action.</p>
<p>This got me thinking about how I might duplicate that technique in Silverlight 2. I figured that the first step was to figure out a simple way communicate between two distinct Silverlight object which exists on the same page.&#160; For this example I am going to have one SL object contain a series of <strong>Buttons</strong>, while the other SL object contains a single <strong>TextBlock.</strong></p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-1.png"><img title="slobjects_1" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="slobjects_1" src="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-1-thumb.png" width="417" align="left" border="0" /></a> </p>
<p>  <br style="clear: both" />
<p>In the image above the red box I refer to as <strong>slObject1</strong>, where the blue box I refer to as <strong>slObject2</strong>.&#160; Both of these &lt;objects&gt; have unique id’s and point to their own respective Silverlight Project and both have been placed in a single html file.&#160; </p>
<p>In this example my <strong>slObject1</strong> will be executing a Javascript function, which in turn will be calling an internal function inside of <strong>slObject2</strong>.&#160; To do this I simply add a reference to the “System.Windows.Browser” namespace and call the Invoke method of the Window object.&#160; here is what my button click handler looks like.&#160; </p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-2.png"><img title="slobjects_2" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="slobjects_2" src="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-2-thumb.png" width="445" align="left" border="0" /></a></p>
<p>  <br style="clear: both" />
<p>Once I have this defined I can now go back into my default.html file and define this Javascript function.&#160; The function finds the appropriate html object and calls the internal function in <strong>slObject2</strong>.&#160; </p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-3.png"><img title="slobjects_3" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="90" alt="slobjects_3" src="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-3-thumb.png" width="509" align="left" border="0" /></a> </p>
<p>  <br style="clear: both" />
<p>To create my “UpdateTextBlock function I need to add a few things to the <strong>slObject2</strong> project.&#160; First I have to go into my App.xaml.cs file and enter the following in my Application_Startup handler.&#160; <strong>“HtmlPage.RegisterScriptableObject(&quot;Page&quot;, page);”</strong>&#160; This registers a managed object for scriptable access by JavaScript code.&#160; Once registered I can create my methods as follows.</p>
<p><a href="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-4.png"><img title="slobjects_4" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="103" alt="slobjects_4" src="http://joel.neubeck.net/wp-content/uploads/2008/07/slobjects-4-thumb.png" width="331" align="left" border="0" /></a></p>
<p>  <br style="clear: both" />
<p>That is all there is to it.&#160; Now that I have the ability to communicate between the two SL object I can go after a more complicated implementation.</p>
<p>Code: <a onclick="javascript: pageTracker._trackPageview(&#39;/code/SLObjects.zip&#39;);" href="/wp-content/uploads/2008/07/SLObjects/SLObjects.zip">SLObjects.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/07/communicating-between-sl2-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
