Persisting the Configuration (Updated)

MiniTutorialLogo

[Updated and expanded on March 5]

HVP-Config-DB For this week’s release of the Silverlight HyperVideo Platform we are committed to having configuration information retrieved from a database. To accomplish this we need (want?)

Smooth-streaming videos that we can use to illustrate the relationship among Items, Topics and Links and

A Database in which to store the configuration information

Step 1 was accomplished by

  • Creating the videos
  • Creating image files
  • Uploading the videos and images to MSN where the videos were encoded for smooth streaming and URLs were returned for the image and for the video
  • Watching the videos and noting where we want to mark topics and links
  • Adding that information to the database

Step 2 was accomplished by creating a Database with four tables

  • Listables
  • Items
  • Topics
  • Links
The Listables table’s relationship with the other three is isomorphic to the relationship between the Listable base class and the derived classes Item, Topic and Link. All of this is captured in the database diagram shown above.

Foreign Keys

[sql]SELECT dbo.Items.ID AS ItemsID,
dbo.Items.ItemUri,
dbo.Listables.ID AS ListablesID,
dbo.Listables.TextToDisplay,
dbo.Listables.ImageSource,
dbo.Items.MyListableID
FROM dbo.Items INNER JOIN
dbo.Listables ON
dbo.Items.MyListableID = dbo.Listables.ID[/sql]
The Sets, Items, Topics and Links tables each represent part of an object, with the remaining part held in Listables. This “normalization” of the database reduces the duplication of data, and thus reduces the likelihood of database corruption.

The Sets, Items, Links and Topics tables each have a column titled MyLinkableId which is a foreign key linked to the key ID field in the Linkables table. This lets us create views such as this definition of the ItemsView

As shown in the image, the column MyListableID in Items and the column ID in Listables are used to join the two tables together into a complete Item.

An Item’s Links and Topics

The second set of connections from each of Links and Topics to the Listables (colored blue) represent the has a ItemsViewrelationship from Items to Topics and from Items to Links.

Thus, the database has captured all the object relationships, but has translated it into relational terms.

The next step is to use the Entity Frameworks to translate back to objects, and WCF RIA Services to create those objects both on the database server and on the Silverlight client.

Adding Data to the Tables

For what follows, assume I have the following videos, topics and links:

Assume I have a set of videos in this relationship

Set – 0 Items:

  • Item – Hypervideo Overview (video)
  • Item- Items and Links (video)

Topics for HyperVideo Overview:

  • Topics and Links
  • Multiple Items
  • Clicking a Link

Links for HyperVideo Overview:

  • Silverlight: Get started
  • Sets
  • MVVM

We will have course have authoring tools for adding this information to the database, but for now let’s add it by hand.

Step 1 – Make an entry for the Set
[sql]– set
insert into Listables (TextToDisplay, ImageSource) values ( ‘ ‘, ‘ ‘)[/sql]
Step 2 – Man entries for the two items

Each entry is in two parts: the “base class” table, Listables, and then the “derived class” Items:
[sql]insert into Listables (TextToDisplay, ImageSource) values (
‘HyperVideo Overview’,
‘http://content1.catalog.video.msn.com/…7928.JPG’)
insert into Items (MyListableID, ItemUri) values
(2,
‘http://msnvidweb….b73822cd9f88.ism’)[/sql]
Step 3 – Enter the Topics for the first item
[sql]insert into Listables (TextToDisplay,ImageSource)
values ( ‘Topics and Links’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (14,13,25)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘MultipleItems’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (15,13,52)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Clicking A Link’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (16,13,85)[/sql]
Note that each of the three topics is entered in two parts, the Listable and the Topic.

Step 4 – Enter the Links for the first item
[sql]insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Silverlight: Get Started’, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (17,13,37)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Sets’, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (18,13,49)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘MVVM ‘, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (19,13,90)[/sql]
We would then enter the topics and links for the first item as well.

Examining the raw data and the relationshiops

When we’re done, we can do some queries to make sure that the data makes sense. First, we’ll examine the Listables table; ListablesResultswe should see the “base” data for the set, for each item and for all the topics and links:

That is, in fact, exactly what we see. Each entry has a unique ID (in this case an integer, in a future release a GUID). Entry 1 is the Set (which has no text or image). Entry 2 is the first Item we entered.

Entries 3-7 are the Listable parts of the Topics for the first item and entries 8-13 are the Listable parts of the Links for the first item.

Note that Listable ID 13 represeents the second item, and that is followed by the Listable parts for the topics and links of the second item.

To see these relationships, we can query the TopicsView to see that the database has captured the Text to display, the offset (in seconds) of where to jump to if a topic is chosen, and the relationship between the Topic entry, its own Listable entry, and the Listable entry for the Item that the topic relates to.
[sql]select TopicsID, MyListableID, TextToDisplay, MyItem, Offset
from TopicsView[/sql]
The result of this query displays 5 columns,

TopicsViewTopicsID is the unique ID for each Topic entry

MyListableID is the ID of the entry in Listable that completes this topic (i.e., the base part of this Topic)

TextToDisplay is the text that will be displayed in the Topics window

MyItem is the ListableID of the item that these topics are for (e.e., Listables 2 and 13 shown above)

Finally, Offset is the number of seconds into the video that clicking on the topic will scrub to.

This work is licensed under a Creative Commons license.
Posted in Mini-Tutorial | Tagged | 1 Comment

When Is It OK To Hack?

MiniTutorialLogo

This mini-tutorial is part of the SLHVP documentation

One of the goals of the Silverlight HyperVideo Project is to demonstrate best practices.  So when is it okay to throw in a quick hack to get things working?

Continue reading

Posted in Patterns & Skills | Tagged , | 2 Comments

The United Kingdom & The Republic of Ireland

I am extremely pleased to say that thanks to the very hard work of Guy Smith-Ferrier, and the generosity of Microsoft UK, Microsoft Ireland, Microsoft User Group Support Services and Microsoft US,  and the work and welcome of numerous user groups in the UK and Ireland, I am able to announce that I’ll be talking at the following events in mid-April.

[ Map ]

(Presentation details below)

Date Group City Talk
12 April The .NET Developer Network Bristol #2
13, 14 April Microsoft Tech Days
Twitter: #TechDays
London
13 April Silverlight User Group / London .NET User Group. London #2
14 April The Next Generation User Group Cambridge #3
15 April Black Marble User Group Leeds #3
16 April NEBytes Newcastle Upon Tyne #3
19 April Scottish Developers User Group Dundee #1
20 April Scottish Developers User Group Edinburgh #2
21 April Dublin User Group Dublin TBD
22 April Northern Ireland Microsoft UG Belfast TBD
23 April Cork User Group Cork TBD

Presentations

#1 Introduction to Application Development With Silverlight 4

This presentation is targeted at .NET programmers new to Silverlight or who wish a review of the fundamentals of building an application in Silverlight 4. Topics will include

  • Drag and Drop development
  • Xaml and Code
  • Layout and Controls
  • Data, Data-binding, Validation and Async-validation
  • Templates and The Visual State Manager (Time allowing)

#2 Silverlight 4,  MVVM and Test-Driven Development

  • MVVM and Silverlight to build test-driven programs
  • Understanding Refactoring and Dependency Injection
  • A Walk through of a non-trivial application

#3 Building A Highly Extensible, Decoupled Silverlight Open Source Application with MEF and RIA Services using Lean, Test Driven Development, An International Team of Volunteer Programmers,  and lots of Advil.

This talk will use the Silverlight HyperVideo Platform open-source project on CodePlex as a case study in building highly extensible Silverlight applications. Among the topics we will focus on are:

  • New features in Silverlight 4 and how they made life easier
  • The Managed Extensibility Framework (MEF) added to Silverlight 4
  • WCF RIA Services for connection to a back-end db
  • Handling inter-module communication when the requirements are that modules cannot assume which other modules will be created, there can be no dependencies on order-of creation and unanticipated modules must be able to communicate with existing modules.
  • Using Markers, Injected Markers and polling to trigger events while viewing a video.
  • A Quick introduction to Lean, TDD and Kanban

This work is licensed under a Creative Commons license.
Posted in z Silverlight Archives | Tagged | 1 Comment

Answering A C# Question

I often receive questions about topics covered in one or another of my books, and I respond, most often, privately. Every once in a while, however, a question comes along that may be of more general interest. This question, though about C#, has a profound effect on Silverlight programming as well…

Question:

… I still can’t figure out when I would need to create an interface when designing my application….

Short Answer

When you want to abstract out what is required from how that requirement is met.

Full Answer

The short answer is correct as far as it goes, but it doesn’t help at all [footnote 1]

The somewhat longer answer is to start with some of the premises of writing Clean Code:

  • Each method should be very short and do just one thing
  • Each class should have one easily articulated area of responsibility
  • Classes should know what other classes do but not how.

Let’s look at how that might play out…

You might start off by refactoring into a Note class and a FileManager class like this:

using System.IO;
using System;

namespace Interfaces
{
   class Program
   {
      static void Main( string[] args )
      {
         var np = new NotePad();
         np.NotePadMainMethod();
      }
   }

   class NotePad
   {
      private string text = "Hello world";

      public void NotePadMainMethod()
      {
         Console.WriteLine( "Here I would interact with you and offer you a writing surface" );
         Console.WriteLine( "Then when you push the right button, I ask FileManager to " );
         Console.WriteLine("print the file..." );

         var fm = new FileManager();
         fm.Print(text);
      }
   }

   class FileManager
   {
      public void Print(string text)
      {
         Console.WriteLine( "I'm pretending to backup the old version of the file and then " );
         Console.WriteLine( " print the text you sent me " );
         Console.WriteLine( " printing {0}" , text );
         var writer = new StreamWriter( @"c:\temp\HelloWorld.txt", true );
         writer.WriteLine( text );
         writer.Close();
      }
   }
}

This console program is stripped of all error checking and all three classes are in one file to keep things simple. The idea is that the NotePad class interacts with the user, obtains a string to print, and then sends it to the FileManager whose job is to see if the file exists, if so make a backup, and then write the user’s text to the file (presumably we’d open a file save dialog rather than just assuming the user wants to write to c:\temp\HelloWorld.txt).

Adding A Second Writer

After creating the above, you realize that there will be times that you will want to write to, e.g., Twitter.  You could put in a branching statement:

using System.IO;
using System;

namespace Interfaces
{
   class Program
   {
      static void Main( string[] args )
      {
         new NotePad().NotePadMainMethod();
      }
   }

   class NotePad
   {
      private string text = "Hello world";

      public void NotePadMainMethod()
      {
         var dest = "Twitter";
         switch ( dest )
         {
            case "File":
               var fm = new FileManager();
               fm.Print( text );
               break;
            case "Twitter":
               var tm = new TwitterManager();
               tm.Tweet( text );
               break;
         }
      }
   }

   class FileManager
   {
      public void Print(string text)
      {
         // write to file
      }
   }

   class TwitterManager
   {
      public void Tweet( string text )
      {
         // write to twitter
      }
   }
}

Adding An Interface

This begins to get ugly, and more important, the NotePad class is now entirely iStock_connectTwoWiresXSmalldependent on both the FileManager class and the TwitterManager class.  It is cleaner, easier to maintain, and far easier to test, if we remove those dependencies.

The first step in doing so is to have the NotePad not know which class will take care of writing the message; all it needs to know is that some class that knows how to “Write” will do the work.  We accomplish this by creating an interface, Writer[footnote b] that has a Write method.

   interface Writer
   {
      void Write(string whatToWrite);
   }

We then have the FileManager and TwitterManager classes implement this interface:

   class FileManager : Writer
   {
      public void Write( string text )
      {
         // write to a file
      }
   }

   class TwitterManager : Writer
   {
      public void Write( string text )
      {
         // write to Twitter stream
      }
   }

At this point, we return to the NotePad and it can instantiate the class it wants as a Writer:

      public void NotePadMainMethod()
      {
         var w = new TwitterManager();
         w.Write( text );
      }

That is step 1 in decoupling the NotePad from the other classes; now all it knows is that it has a Writer, which can be one or the other of the streams (or any other class that implements that method) but we’re hard coding which implementing class to use (in this case TwitterManager) in the NotePad class… not great.

Dependency Injection

iStock_InjectionRedXSmall Dependency Injection is one of those terms you really want to work into your conversation at every conference you attend. It marks you as a cutting edge, in the know kind of geek.

Here’s how it works.  You don’t want to hard-code the dependency into NotePad because that makes for code that is hard to maintain and hard to test (the technical term is “bad.”)

What you can do, instead, is “inject” the dependency at run time. You can inject in a number of ways, the most common of which are:

  • Constructor injection
  • Property injection
  • Parameter injection
  • Using a Factory
  • Using an Inversion of Control (IoC) container

(Yes, IoC container may be even cooler than dependency injection. More on IoC below, but not much more)

Constructor injection just says that we’ll let the Notepad know which type of writer it is going to use when we create the class:

   class NotePad
   {
      private string text = "Hello world";
      private Writer w;
      public NotePad( Writer w )
      {
         this.w = w;
      }

      public void NotePadMainMethod()
      {
         w.Write( text );
      }
   }

Notice that we pass in an instance of Writer, stash it away in a member variable and then NotePadMainMethod just uses it.  The actual instance is not created in NotePad, it is created in whomever instantiates the NotePad and “injected” into NotePad through the constructor.

Property Injection works the same way, but instead of passing in the writer through the constructor, you set a property,

      public Writer MyWriter { get; set; }

      public void NotePadMainMethod()
      {
         MyWriter.Write( text );
      }

Now whoever instantiates MyWriter just sets the property and NotePad can take it from there.

Parameter Injection, as you can, by now imagine, eschews having a member variable, and just passes the type of writer into the method as a parameter

      public void NotePadMainMethod(Writer w)
      {
         w.Write( text );
      }

Factory Pattern and IoC Containers

Each of these three approaches has its advantages, but none of them scale very well. To solve this problem, developers often turn to the Factory Pattern which allows for another level of indirection: an object that creates other objects (the factory).  We won’t go into that as it isn’t essential to understanding interfaces, but I will also mention that beyond the Factory, when you want the ability to “compose” your application at run time, with totally decoupled objects (that is, at run time you’ll decide what writer the NotePad will use, and neither the writer nor the NotePad need depend on the other) you can then turn to Inversion Of Control (IoC) containers; a big topic covered in some detail here, and here.

The Curve, and Being Behind It

Reading Scott’s great review of Alt.NET and Open Spaces and many topics related to the above; I am reminded of a cartoon in which you see a man and woman in a tree, while others are running by holding torches, and the woman says to the man, “How come it seems like everyone else is evolving but us?

More from me on Open Spaces, Dependency Injection, Alt.Net and much else coming soon. You can join me in working through all this while creating a truly amazingly fun open source project here, the documentation for which is here.

jessesig

—-

footnote 1: Old joke: two guys are in a helicopter over Washington state, and the fog comes in too fast; they are totally lost and running low on fuel.  The chopper pilot pulls up next to an office building, knocks on the window and when a man comes to the window, hollers “Where am I?”

The guy looks at him and says “You’re in a helicopter” and shuts the window.

The pilot flies directly to the airport and lands safely. His passenger, stunned, asks him, “how did that help?”  “Oh,” says the pilot, “I was in a life and death situation, and asked a perfectly reasonable question. He gave me an answer that was both true and totally unhelpful; so I knew right where I was: Microsoft Tech Support.”

(With apologies to the terrific and truly helpful people at tech support, who will please have a sense of kajf;320 <abend>)

footnote b: Notice that my interface is named Writer, not IWriter.  I’d like to say that I had the courage of my convictions to stop putting the Silly I in front of every interface (IWrite, IClaudius, IThinkThereforeIAm…) but it took reading Bob Martin’s wonderful book Clean Code to get me to step up.

This work is licensed under a Creative Commons license.
Posted in Mini-Tutorial | Tagged , | 4 Comments

Behind the Curtain

Our team (officially Community Program Managers, with the secret identity of STO Ninjas) has quietly expanded over the past few StoNinja50 months, including the additions of two amazing and terrific new voices: Pete Brown and Jon Galloway.

Their names are linked to their blogs, which I highly recommend subscribing to.

 

 

 

Syntax Highlighting (Finally) Done Right

This posting, however, is occasioned by Jon writing a post on how to make Syntax Highlighter work with Community Server… no small trick, but Syntax Highlighter now supports hosting (!).    Jon provides all the links you need (including a link to our fearless leader’s extensive post on the topic) , and great instructions,

The key benefit is that the code has syntax highlighting but still support clean copy and paste; something I’ve wanted (and readers have demanded) for a long time.

Here’s an example:

using System;
using System.Collections.Generic;
using System.ComponentModel;


namespace SilverlightHVP.ViewModel
{
   public class ItemsViewModel : INotifyPropertyChanged
   {
      private State state;
      public List<Item> Items
      {
         get { return state.CurrentItems; }
         
      }


      public Item CurrentItem
      {
         get { return state.CurrentItem; }
         set 
         {
            if ( value != null )
            {
               state.CurrentItem = value;
               NotifyPropertyChanged( "CurrentItem" );
            }
         }
      }

      public ItemsViewModel( State state )
      {
         this.state = state;
         this.state.CurrentSetChanged += 
            new State.CurrentSetChangedHandler(state_CurrentSetChanged);
         UpdateItems();
      }

      void state_CurrentSetChanged( object sender, EventArgs e )
      {
         UpdateItems();
      }

      private void UpdateItems()
      {
         NotifyPropertyChanged( "Items" );
      }


      public event PropertyChangedEventHandler PropertyChanged;
      private void NotifyPropertyChanged(string propName)
      {
         if (PropertyChanged != null )
         {
            PropertyChanged(this, new PropertyChangedEventArgs(propName));
         }
      }
   }
}

syntax If you are looking at this on line, you should see a very nicely formatted layout with syntax highlighting (see image).  In a stream, however, it is straight html.  Even more valuable, notice the four symbols (circled in red); when you click on the code these appear and offer “show source” (the image has an inlay of the source as it is shown when clicking this). The other three are copy to clipboard, print and help.  Very very nice.

Thanks Jon!

(Click on image for full size)

This work is licensed under a Creative Commons license.
Posted in z Silverlight Archives | Tagged | Comments Off on Behind the Curtain

Test Driven Silverlight Body Snatchers

MiniTutorialLogo

SLHvpLogoNoBorderThis posting is part of the Silverlight HyperVideo Platform documentation and a Silverlight Mini-tutorial. The information in this posting, however, should be of interest to anyone writing meaningful Line of Business applications with Silverlight.

The premise of the classic 1956 film Invasion of the Body Snatchers is that there are “pod people” among us, who are converting “normal” people into pod people one by one.

“Once you are a pod person, you think everyone should be one”

Once you begin seeing the benefits of TDD you tend to evangelize; its working great for you and you want everyone to become one.  This can be helpful, annoying or alarming depending on who you’re talking to.  My daughters, for example, are quite sick of hearing about it.

Continue reading

Posted in Mini-Tutorial, Patterns & Skills | Tagged , , | 1 Comment

Configuration & Decoupled Modules

MiniTutorialLogo

SLHvpLogoNoBorder

Two architectural demands for the Silverlight HVP, which are common to many larger applications, came together this week and crystallized into a design that looks to solve a couple other, unanticipated requirements.   Specifically, we knew that (1) we wanted to have configuration files and that (2) we wanted each module to be created independently of all the other modules. After some discussion, thrashing, input from some great folks at CodeMash, and further review, the design that has emerged allows us to implement two other less thought-through requirements: (3) the ability to restore the state of the application to an earlier condition and (4) the ability to save the state of the application when it is shut down.

Continue reading

Posted in HyperVideo Player, Mini-Tutorial | Tagged , | Comments Off on Configuration & Decoupled Modules

Silverlight HVP Proof Of Concept Released!

SLHvpLogo

I’m incredibly proud to say that we were able to release the Silverlight HVP proof of concept alpha release on time, at 12:05 am Wednesday January 6, 2010 (GMT-5).  As noted in our release schedule this is the first of a series of releases scheduled for every second Wednesday.the dancer

While this first release exceeds what we promised for the Proof of Concept, it is still very much a hard-coded representation of what we plan to release in the  coming weeks. Our first major release will be in two weeks, on January 20, when we swap out the hard-coded modules and swap in the mef-based dynamic modules that show the true colors of our emerging design.

Key Features in the Proof Of Concept

  • Silverlight Media Framework player subclassed and placed in a view
  • Table of contents with hard-coded but live links that seek to the appropriate spot in the streaming video
  • Table of links with hard-coded but clickable links that appear at designated times as the movie progresses

Thanks to all for your continuing support.

Posted in HyperVideo Player | Tagged | Comments Off on Silverlight HVP Proof Of Concept Released!

Rapidly Evolving Design

SLHvpLogo

The problem with using a blog to track a rapidly evolving design, is that blogs don’t make for very fluid documents; the unwritten rule is that once posted, you ought not go back and substantially alter a post.

Matching Blog Posts to Discussions

I do want to use these postings to keep everyone up to date on the evolution and lessons being learned in the SLHVP project, but we also need a way to consolidate the discussion and the evolving understanding, and so each blog post will refer to a specific discussion on CodePlex where the ideas will be discussed and will evolve. I’ll then post a roll up of changes periodically, but not in response to each posting. The most recent post is being discussed here, where I have recognized that I violated my own design principles and backed away from two lines in the previous blog post. Here is what I wrote:

 

Your questions reveal that I have violated my own design principles: "Do not let the design get ahead of what you know" — The right answer is, of course, to design only for what we know we need, and keep the design open enough to extend as new needs emerge. To answer your questions specifically:

…What I meant was that we know that videos will want to signal a marker has been encountered, and I can imagine that other frame components might want to signal that something has happened that is equivalent (you’ve reached the 4th level of play in this game)… then I went off the track and speculated that this should be handled by the Frame. But that is absurd.  The Frame might be the place to handle this, but I can easily imagine that there is a base class or interface that the video and game support or that there is a separate class they both associate with, etc. etc.  So let’s just strike that statement (which I will do by editing my message and referring to this discussion.

2. [Each module will have its own xml config file] Here is where I really went over the edge. I totally retract this statement. Maybe it makes sense for each module to have its own configuration file, but we’ll only know that once we have modules and we’ve worked with a single integrated configuration file (the manifest you have working). So let’s please stay with the manifest until it is manifestly not working 🙂

Please do join us in the ongoing discussion. Feel free to leave comments here about the form of the post, but substantive comments about the project will be seen by the most people, and those most involved, in the ongoing Discussions.

Thanks

 

jessesig

This work is licensed under a Creative Commons license.
Posted in HyperVideo Player, Patterns & Skills | Tagged , | Comments Off on Rapidly Evolving Design

Worth A Thousand Words

SLHvpLogo

In responding to a discussion on the HVP, I generated this image, which I think goes some way towards clarifying the recent posts.

ModuleNames
(Click on image for full size)

The discussion is here

As an aside, the best Greeking engine I’ve found is here; and, wonderfully, it also generates techno-babble.

Posted in z Silverlight Archives | Tagged | Comments Off on Worth A Thousand Words

Extending the SLHVP Player to be a Platform

This post is part of the Silverlight HyperVideo Platform  documentation

[Updated 1/5 10:50 GMT-5]

Everything Flows, Nothing Stands Still – Plato
Nothing Endures, But Change – Diogenes

The past few days have seen quite a flurry of design activity, and I’m quite sure some folks who have been following closely have been confused. This note will clarify, and also discuss design decisions made to move the project forward, and why these decisions were made. I have created a new discussion on the CodePlex site and I would invite your comments and feedback there, if that is convenient for  you.

Original Goals:

  • Build a HyperVideo player which would provide a better way to play our instructional (How Do I) videos and
  • Annotate the process from design to completion in a series of blog posts, as a way to discuss virtually every aspect of Silverlight

OpenSource and CodePlex

We decided to move the project to CodePlex (which took a few  months to get licensed) and open the project up to community involvement.  This is a wonderful thing, and has created unanticipated opportunities.

My perspective on this project, buttressed by management expectations, is to foster as much community contribution as possible, but to take personal responsibility for every line of code in the project, to set coding standards, and so forth.

The project is being built with MEF which makes it composible and extensible. I envision 6 classifications for code created by the community

  1. Code accepted into the core project (process has been detailed on the Developer Page.
  2. Code accepted into the plug-in extensions within the project
  3. Code that needs further work to meet coding standards but we anticipate accepting
  4. Modules that have been rejected as inconsistent with the project, but which can be housed outside of the project (even on another CodePlex project)
  5. Modules that a person or company develops intending to make them proprietary but to work with the project.

Key to this is that the first two represent code that will be in a release from the project, and the fifth option is open to any organization, commercial or otherwise, so long as they follow the Ms-PL license.

The Contributions and Influence of WL

As you may know, we have a commitment from WL (an e-learning startup) for 100 hours/week of developer time. They already have some code working that they are interested in adapting to this project and contributing to the core. Their stated intention is to contribute all this work into Ms-PL licensed code housed on CodePlex and also to try to build a product or products using the SLHVP as the engine.  That, as I read the Ms-PL is more than appropriate.

Two concerns comes to mind, and this was surfaced by WL itself from day 1:

  1. Will they distort the project to meet their own needs in a way that either precludes a more general use or freights the code with only tangentially relevant parts and/or
  2. Will they add complexity that we otherwise would not have

After working carefully with them and examining what they need and want, and what will be best for the project, I can unequivocally answer no to #1 and I can give a more nuanced answer to #2.

The short version is that they bring a more complex design, and with it they bring far greater flexibility and mission-appropriate features. Thus, yes, the project will end up more complex with their involvement, but it will not end up with unneeded or irrelevant complexity.  To be specific, all the additional complexity will be in service to features that are appropriate for the project.

Expanding the Scope

This would not work if I were to cling to an initial limited vision of the product, but it works great if we lift our vision a little higher.

I had a boss who said (paraphrasing):  “If the railroad companies had realized they were not in the rail business but the transportation business, we’d all be flying Union Pacific Airways.”

One very important aspect of my role in Microsoft is to provide “educational material” such as videos and mini-tutorials, but an arguably more important job is to explore new ways of conveying this information that greatly enhance customer satisfaction and involvement. That can be done by responding to user-suggestions and concerns (which we try hard to do) and also by exploring relatively radical new ways of conveying this information.

The Silverlight HyperVideo Platform

Over the past couple weeks the project has been re-conceptualized in somewhat broader terms, as evidenced by the new summary statement:

The SLHVP is an extensible HyperVideo platform to orchestrate media, data, user-experiences, and social-interaction into compelling applications.

What this means is that the SLHVP now anticipates providing more than just video and web links, but also, over time, animation and possibly interactive elements. To accomplish this, we are working towards the following key aspects of the design; most of which should be in place by the January 20 release

  • The application is a shell that loads its components via MEF
  • Each component stands alone, is configured from its own xml file
  • All configuration information is provided from one or more databases using WCF RIA Services
  • Each component publishes its events, and each event provides information for consuming modules in a class derived from EventArgs
  • Event management will be mediated by a class associated with the application; we are exploring Prism’s EventAggregator
  • Each component consumes those events that are of interest to it

We have identified the following modules for the first release

  • The Viewer – responsible for instantiating Frames
    • Frames are a way to display one or more control within the viewer – full design to come soon
  • The Derived SMF video player – essentially the SMF player adapted to work within our architecture
    • This will be the primary way to display videos
  • Frame will support a “Location Reached” event that can be triggered by (among other things) We will need to handle the following occurrences and others much like them  [updated 1/5 – please see this discussion]
    • An injected marker being reached
    • A marker being reached
    • A position (elapsed time) in the video being reached
    • A location event from within a frame being fired
  • The ItemsListView that displays all the items that will be displayed in this session (this could be a single video, a series of videos, etc.)  The ItemListView will be subclassed to allow for various types of lists, including ordered lists and maps.  For V1 we will most likely have just an ordered list (display video a, b, c in that order)
  • The PostiionListView – either a stand alone module/viewer or one combined with the ItemsListView that allows seeking to specific locations within an item – this would be used, for example to seek to a specific topic within a video
  • The LinksView – some items (notably videos) will have a set of links that will either appear all at once or, more likely, as the topic they relate to is mentioned in the Frame.  These links will, typically, pause the current frame and cause a new frame to be created – e.g., will open a new video or a web page, or animation, etc.

The current (not yet released) code has a single xml file for creating all of these modules, but even if that is what we release on Jan 20, by early February each module will have its own configuration file. The format for these files will be well-established, and we’ve nearly finalized that already. [updated 1/5 – please see this discussion]

As the first set of code comes from WL and our other contributors I will expand upon these descriptions and update our feature and task list accordingly.

Thank you all for your ongoing support and patience as we sort this out. I anticipate a great burst of productivity over the next six weeks or so.  Please be sure to see the newly updated schedule.

This work is licensed under a Creative Commons license.
Posted in HyperVideo Player, Mini-Tutorial | Tagged | Comments Off on Extending the SLHVP Player to be a Platform

Configuration Files for Silverlight HVP

MiniTutorialLogo

SLHvpLogo
This mini-tutorial is part of the Silverlight HyperVideo Project documentation.

Taking Risks

One of the great pleasures, and total terrors of documenting this open-source application is that occasionally I have to offer up some half-baked ideas that risk displaying how little I know about a particular topic, but which are necessary to generate discussion. Caveat: this is such an entry.  I could have put this into the project documentation but I saw an opportunity to widen the audience on a topic that is important to Silverlight Programmers, even if not part of Silverlight itself.

Goal

 

We want the modules in the Silverlight HVP to be as flexible as possible. Towards that end we’ve adopted two strategies:

  • Using the Managed Extensibility Framework (MEF) to make every module composable and extensible.
  • Using XML files to provide Just In Time configuration for each module.

XML Schemas

It will greatly simplify everyone’s work if we have agreed upon schemas, at least for the configuration files we know about:

  • slhvpInit.xml – initialize the application
  • slhvpTOC.xml – create a table of contents for a video
  • slhvpLinks.xml – establish which links will appear while a video runs and what to do when the user clicks on each

As a necessary first step, I’ve sketched out examples of slhvpTOC.xml and slhvpLinks.xml – these are not intended to be complete, but to generate discussion. They are posted here as a way to invite more folks into that discussion.

slhvpTOC.xml (draft example)

<?xml version="1.0" encoding="utf-8"?>
<ConfigFile Name="TOC Configuration File" 
            Guid="687DA074-8F94-43a9-AC23-46DF823F8A65"  
            xmlns=http://slhvp.com/TOC>
  <ConfigurationMetaData>
    <Version>0.0.1</Version>
    <Purpose Summary="Create a Table of Contents for a video" />
    <![CDATA[
    This configuration file is used to create the table of contents. The topics are listed as links, which cause
   the video to seek forward or backward to the designated topic.
     ]]>
     <Module Name="slHVP Standard TOC Module version 0.1" 
             Guid="D3E2AC2B-FD34-40b4-BC42-308F7956C7D9" />
     <CreatedDate Format="AmericanShort" Date="01/01/2001" />
     <Conditions>
       <Condition Name="Advanced"
                  Value="True" />
     </Conditions>
   </ConfigurationMetaData>
  
   <ConfigurationData>
   <TOCEntries>
     <TOC>
       <Type> TOC </Type>
       <SeekTo>
         <SeekToTime>00:00:10:000</SeekToTime>
       </SeekTo>
       <Text> Introduction </Text>
     </TOC>
     <TOC>
       <Type> TOC </Type>
       <SeekTo>
         <!-- Seek directly to an injected or existing marker -->
         <SeekToMarker ID="LINQ" />
       </SeekTo>
       <Text> Introduction to LinQ </Text>
     </TOC>
     <TOC>
       <Type> TOC </Type>
       <SeekTo>
         <SeekToTime>00:20:10:010</SeekToTime>
       </SeekTo>
       <Text> MVVM </Text>
       <!-- Designate that this entry in toc is only idsplayed if 
       the Advanced condition has been set to true -->
       <Visibility Condition="Advanced" RequiredValue="True" />
     </TOC>
   </TOCEntries>
   </ConfigurationData>
 </ConfigFile>
  

The file consists of a header (lines 2-4) and two major sections – the meta-data (lines 5-19) and the listing of the (abridged) Table of Contents entries (lines 22 – 48). Notice that the final TOC entry (lines 38-47) is visible only if the condition “Advanced” is set to true, which it is in the Conditions section int eh meta-data (lines 15-18.

slhvpLinks.xml (draft)

<?xml version="1.0" encoding="utf-8"?>
<ConfigFile Name="Links Configuration File" 
            Guid="83ca650e-25ff-414d-adef-7aa790f9d858"  
            xmlns="http://slhvp.com/Links">
  <ConfigurationMetaData>
    <Version>0.0.1</Version>
    <Purpose Summary="Link time to hyperlink to action" />
    <![CDATA[
    This configuration file is used to create linkage among an elapsed time in a How Do I video with
     the text of a new link to display at that time and then with the action to take based on the new link being clicked
     ]]>
     <Module Name="slHVP Standard Link Module version 0.1" 
             Guid="FB252D52-A603-4bf4-89C8-AA64E52D0343" />
     <CreatedDate Format="AmericanShort" Date="01/01/2001" />
     <Conditions />
   </ConfigurationMetaData>
  
   <ConfigurationData>
   <Links>
     <Link>
       <Type> Hyperlink </Type>
       <Time>
         <!--Time format is hh:mm:ss:msmsms-->
         <StartTime>00:00:00:000</StartTime>
         <!--Undefined end time - visible to end of video-->
         <EndTime>0</EndTime> 
       </Time>
       <Text> About this video </Text>
       <Action> WebPage </Action>
       <URL> http://jliberty.com/aboutHyperlink.htm </URL>
     </Link>
     <Link>
       <Type> Hyperlink </Type>
       <Time>
         <StartTime>00:05:11:010</StartTime>
         <!--End time of 0 or missing end time both mean no end time, run to end-->
       </Time>
       <Text> What is Linq </Text>
       <Action> Video </Action>
       <URL> http://silverlight.net/learn/video#103 </URL>
     </Link>
     <Link>
       <Type> Hyperlink </Type>
       <Time>
         <StartTime>00:12:00:110</StartTime>
       </Time>
       <Text> Linq Programming Animation </Text>
       <!-- video pauses and is replaced by animation frame -->
       <Action> Animation </Action>
       <!--Required either a URL or a guid to a frame-->
       <GUID>
         E40D045A-4AC4-4ea9-8501-58F0E0407F61
       </GUID>
     </Link>
   </Links>
    </ConfigurationData>
  </ConfigFile>
   

You can see that this format is quite similar to the TOC format, and one open question is whether we need an inclusive schema.

In this file, each Link has a type, where some of the possible values are

  • HyperLink (link to a URL)
  • Animation (link to a frame that supports animation
  • Text (link to a frame that displays non-html text)

 

Purpose of this posting

To reiterate, briefly, I have two goals with this posting:

  1. Generate discussion about what needs to be in the configuration files and whether this is a reasonable starting point and
  2. Follow through on the implications of my thinking about markers, links, etc.

Note that this topic is also under discussion here which is a great place to continue the discussion.

This work is licensed under a Creative Commons license.
Posted in HyperVideo Player | Tagged , | Comments Off on Configuration Files for Silverlight HVP