Expression Encoder SDK is out!
- Posted: Jun 05, 2008 at 3:01 PM
- 1,003 Views
One of the neat features of Expression Encoder 2 we've been talking about is its .NET object model interface for automation. I'm happy to report that it's now available for download!
It includes a number of sample projects (quoting from the help file). These are a good jumping off point for various scenarios.
The simple encode sample is a console application that demonstrates how to encode a file from a console application when showing progress. To use it, just run the built application (Simple.exe) at a command prompt.
The WPFEncode application demonstrates how to encode a file from a UI application when displaying the progress of the encoding process. To use the application, click the Browse button to point to a file that you want to encode and then click the Encode button to encode it. When the file is encoding, a bar displays the encoding progress.
When you press the Encode button, the application creates a thread to perform the encode to make sure that the UI thread is not blocked. The progress events are called from a non-UI thread. Consequently, we use the Windows Presentation Foundation Dispatcher to marshal the updates to the UI thread.
If you try to close the application when the encoding is still occurring, the application prompts you to confirm that you want to stop the process. If you confirm, the application stops the encoding thread but delays closing the application until the thread actually stops.
Publishing plug-ins enables you to take video and Microsoft Silverlight template assets that you have created as part of an encoding job and then do something with encoded assets. For example, you can upload the media asset by using FTP, WEBDAV, or METAWEBLOG API, publishing the asset to an asset management system or web service, or creating a data CD.
The following code sample demonstrates how to use a publishing plug-in to add the output of an encode job to a Zip file by using the Open Packaging Convention components found in Microsoft .NET 3.0.
A publishing plug-in is required to derive from the PublishPlugin class, which in turn derives from the EncoderPlugin class:
The template plug-in lets you customize template settings and interact with the job through the IPluginHost interface. The plug-in also lets you add or remove files from the template output when the template is published.
The following code sample demonstrates how to add the default template parameter control to Microsoft Expression Encoder with only several lines of XAML. It also implements a custom script command creation feature that shows how the template plug-in can interact with the current job by adding a script command at the current play head position of the selected MediaItem.
Within Expression Encoder, every template receives a template plug-in. If the template doesn’t specify one, a default one will be assigned. A template plug-in derives from the TemplatePlugin class, which in turn derives from the EncoderPlugin class.