Simple EventArgs in Silverlight

In my previous post, I talked about the Silverlight Media Framework (SMF).  As the name implies, SMF is so much more than a video player, it’s a framework.  The project is rich with nuggets of Silverlight goodness; today I would like to pay homage to one of my favorite classes: the SimpleEventArgs (in Microsoft.SilverlightMediaFramework).

Have you ever been in a scenario where you just want to pass an object through an event the EventArgs without having to create custom EventArgs for each type of event?  SimpleEventArgs solves this by using generics, and asks only for the class.  This one class has saved me countless amounts of time by not having to code up custom EventArgs.

Almost forgot…SimpleEventArgs are Scriptable by default, making this class available from JavaScript.

Thanks guys SMF team.

FULL DISCLOSURE: This code comes directly from the Silverlight Media Framework (http://smf.codeplex.com) project.  Visit the project to get the complete source.

image

Open Source Silverlight video players

image Lately I’ve been spending a lot of time in the Silverlight video space.  Both with writing the video chapter for my Silverlight 4 book as well as at work.  Creating a basic video player is straight forward (link 1 | link 2), have a button to play, a way to control the volume, a scrubber to show the position of playback, and of course an area to view the video. 

Once you get beyond the basic requirements, the “basic video player” becomes very involved.  A few questions that will need attention are:

  • “How do you handler markers?”
  • “How is streaming video handled?”
  • “What do you do an an error?”
  • “What’s the strategy for buffering?”
  • “Can the video player support Smooth Streaming content?” (this is a whole different conversation)
  • “How does the video player handle Closed captioning?”

And on and on the list goes.  At some point (hopefully in the analysis phase) you should ask is it better to build or buy.  If you decide to build, give me a call ;), but before you do I would encourage you to take a look at the following open-source (free) Silverlight video player options.  If nothing else, these players are great place to start.

I’ll start off with the three best options, then highlight other projects I am less familiar with.

Silverlight Media Framework (SMF)

http://smf.codeplex.com/

This is so much more than a video player, it’s an entire framework.  Developed by Vertigo in coordination with Microsoft, SMF has been used on the largest, most watched, Silverlight video players to date.  Wimbledon, NFL’s Sunday Night Football, PDC live keynote, and the NBC’s Vancouver Olympics video players, to name a few, all use SMF.  To say it’s robust would be an understatement.

Other than the standard video player controls, here are additional highlights of SMF:

  • Smooth Streaming support – includes the Microsoft.Web.Media.SmoothStreaming.dll
  • Great base classes like MergeableCollection, SimpleEventArgs and ObservableObject
  • A light weight data project
  • Logging
  • Blendability – the player is easily skinned
  • InStream markers
  • Bitrate – the ability to show bitrate

For a more detailed list of features, and the code, check out SMF’s site.

Silverlight Video Player

http://slvideoplayer.codeplex.com/

If you have ever watched a video on Channel 9 (if you haven’t check out Silverlight TV) the player being used is this video player.  It was developed by Tim Heuer (Microsoft) and Joel Nuebeck (Silverlight MVP).  Although SVP does not the feature set the SMF player has, this is still a solid and proven video player.  It’s is probably the best option for a standard, light weight, feature rich video player.

Silverlight HyperVideo player (HVP)

http://slhvp.com/

A new video player to the scene is the Silverlight Hyper-Video Player (HVP).  This offering is from Jesse Liberty (Microsoft) and the Community.  Targeting Silverlight 4, HVP takes advantage of the MEF framework and is rooted in best development practices.  Although the project is young, there is a lot of traction and Jesse is doing an amazing job of documenting each step.  Keep on eye on HVP as this maybe the most scalable offering.

Others

The above three video players I have personally used, dug through the code, and/or evaluated.  The following projects I am not as familiar with, but could be possible options for your scenario:

Sharepoint video player - http://svp.codeplex.com/

Silverlight Media Player http://silverlight30.codeplex.com/

xLite player - http://xliteplayer.codeplex.com/

Atlanta Silverlight – Jan 20, 2010

image

Two night and two user groups.  Last night we had the Atlanta Silverlight User Group featuring Jeremy Likeness , senior consultant with Wintellect, presenting on Silverlight Line of Business applications.  Jeremy’s session highlighted on Silverlight frameworks, MEF, Unit testing, services, and briefly on Blend.  We did do a screen capture of the session; as those details become available I’ll post more.

The turn out for the group was amazing.  All in all we had almost 50 people.  Thank you all for coming out.  Next month Roger Peters will be presenting on Building a Compelling UX with Silverlight.

If you have a topic that you would like to present on, visit the Meetup page and drop me an e-mail.

See you next month.

Silverlight and Drupal

image 

Last night, Jan 19th, I attended the Atlanta Drupal User Group (ADUG), http://www.drupalatlanta.com/,  with Glen Gordon.  The talk, presented by Steve Jaffe of IBM, was about “Integrating Flash with your Drupal Project”.  Steve did a great job of how Drupal can be used as the backend for Flash.  Never having used Drupal, the same techniques presented can be use for connect to Silverlight.  In fact, after some digging around, it looks like someone has already been playing around with Drupal and Silverlight…Matt Serbinski.  Here are a couple of his articles:

Silverlight 4 WebCam - a quick glance

WebCam support in Silverlight 4 is a much anticipated feature, and probably didn’t come as much of a surprise.  It’s relatively simple to enable this feature.  The below example shows a simple UI with the code to enable the webcam.  This post does not cover multiple webcams, however calling CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices returns a list of all available webcams.

First create a simple UI (a Rectangle and a Button).

image

Add an event to the button click event.  The logic looks like this:

  • Get a handle on your video capture device using CaptureDeviceConfiguration.
  • Request access to the device with CaptureDeviceConfiguration.RequestDeviceAccess().
  • If the user clicks Yes, then create a CaptureSource object and set the VideoCaptureDevice to the selected webcam.
  • Create a VideoBrush
  • Set the Source of the VideoBrush
  • Start the webcam
  • Paint the Rectangle (this could be anything that takes a Brush)

image

Next step, F5 (run your app).  You’ll be looking at a blank screen with a button.  After clicking the button, a box appears prompting the user to allow access to the webcam and microphone.  Click Yes, since after all that is our goal ;).

image

Voilà!! You are now looking at yourself. Now you can do all sorts of fun web cam stuff.  Enjoy.

image

Tip

After running the above app, I noticed it was backwards.  Meaning when I moved left my face on the screen moved to my right.  Maybe it’s just me, but my brain was not happy about this.  Instead, I wanted the app to respond like a mirror.  To do this was a quick fix; simply Flip the Rectangle on the X axis.  Here is the menu in Blend to do this:

image

More info

For more information, Tim Heuer has a great video covering Web cam and microphone support in detail: http://silverlight.net/learn/videos/all/access-web-camera-microphone/

Changing your default WebCam & Mic – Silverlight 4

Webcam and microphone support are a much anticipated feature to Silverlight 4.  If you have more than one webcam or audio input device, it’s possible to change your default device. Right click on your application > Click Silverlight > Webcam/ Mic.  Here you will find a menu where you can choose your default devices.

image

NotificationWindow – Silverlight 4

A new addition to Silverlight 4 is the NotificationWindow.  This type of window enables you to show a System notification much like when you receive an Outlook new mail notification or a Growl notification in OSX. Since it operates like a system message, this feature is only available in Out of Browser (OOB) scenarios.

This example shows how to instantiate a NotificationWindow, with the resulting application like the below screenshot.

image 

Code

And now for the code. The items to note:

  • In the Tick event check to see if the application is running in OOB.
  • If yes, then instantiate a NotificationWindow object.
  • Set the Content (this could be as simple as a TextBlock or a custom UserControl)
  • To show the Notification, call the Show method specifying, in milliseconds, the duration of the Notification.

image

 

image

Q: Can I show multiple notifications?
A: No, there isn’t a queue.

Q: Can the user interact with the NotificationWindow?
A: Yes, but only mouse support.

Q: What is the size of the NotificationWindow?
A: 400×100 (btw, I love Pixus)

image

 

Q: Can the NotificationWindow be customized?

A: Yes, below is a screenshot of the notification window using a custom UserControl instead of a TextBlock like the above example.

image

Silverlight 4 – new features

When Silverlight 3 debuted at MIX09, there were a number of places to find information about the new features, so better than others.  Unfortunately I never remembered the sites and always relied on Google to produce the site for me.  This time will be different; this post will serve as my place for SL4 info.

image
http://silverlight.net/getstarted/silverlight-4-beta/

 

image 
http://blogs.silverlight.net/blogs/jesseliberty/

 

image
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx

 

image 
http://geekswithblogs.net/WynApseTechnicalMusings/archive/2009/11/18/136394.aspx

 

image
http://wildermuth.com/2009/11/18/Silverlight_4_Beta_Announced!

Check if running in Out of Browser - Silverlight

As Silverlight increases its Out of Browser features it will become more important to detect if the application is running in or out of the browser.  This is the check:

image

This was a quick one.

Behavior driven development

A session that caught my eye from PDC was a session titled Behavior driven development vs Test driven development.  I don’t think this session had direct ties to Silverlight, however it made me think about Silverlight Behavior development.  Could this be a topic?

Lately I have been a big advocate about using behaviors for UI interactions when developing a Silverlight app.  Behaviors enable me to quickly develop a rich UI without much code and focus on functionality.

This is a quick thought, and more to come about it, but wanted to throw it out there.  In the meantime check out

http://www.85turns.com/2009/10/14/top-5-silverlight-behaviors/