Basic code to encode a file

Here's a very small snippet of code that uses the Expression Encoder object model to create a job, add a media file to the job and then encode it. There's a lot more to the object model, but I thought this would give a little taste of the basics. In the object model we wanted to expose most features of the full Encoder application, but we also wanted to make sure the user could do the simple operations without having to write a lot of code.

 public void EncodeAFile()
{
    // Create a job and a media item for the video we wish to encode
    Job job = new Job();
    MediaItem mediaItem = new MediaItem(@"C:\input\MyVideo.avi");
    // Add the media item to the job
    job.MediaItems.Add(mediaItem);
    // Set the output directory where any encoded files will go.
    job.OutputDirectory = @"c:\output";
    // Set up the progress callback function
    job.PublishProgress += new EventHandler<PublishProgressEventArgs>(OnPublishProgress);
    // Encode the file
    job.Encode();
}

void OnPublishProgress(object sender, PublishProgressEventArgs e)
{
    Console.WriteLine(e.Progress);
}