Encoding markers using Expression Encoder
Expression encoder provides a wealth of functionality for encoding videos. For this tip we are going to focus on marker encoding. When you encode a marker you are simply injecting some metadata at a certain point in your video. Videos can have as many markers encoded into them as you like and there are many scenarios where video markers will come in handy. For instance you might be developing an interactive application where an animated tour guide speaks over your video at certain high points. A simpler scenario would be displaying textual caption information as your video progresses.
Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial DirectorResponding to markers using WPF
Responding to encoded markers in WPF is quite simple. Once you have some script commands encoded within you video it's as simple as setting up an event handler. On the WPF MediaElement object you have access to an event call ScriptCommand. When one of your markers is reached any attached script command event handlers will fire giving you access to the meta-data encoded with that script command.
Responding to markers using Silverlight
Responding to encoded markers in Silverlight is also quite simple and not much different from the WPF implementation. Silverlight also provides an event off of the MediaElement object which fires when encoded markers are reached. In Silverlight these are called TimelineMarkers and the raised event is called MarkerReached. Inside of your MarkerReached event handler you will have access to the meta-data encoded for the current marker.
Conclusion
Using the techniques described in this tip you will be able to easily encode markers in videos which you then react to in your Silverlight or WPF applications. As a next step it would not be incredibly difficult to enhance the WPF MediaElement object to support the same marker adding functionality as the Silverlight MediaElement.
This was first published in October 2009