×

First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

i've been asked recently why i use the template code in my samples for media playback in .  simple: free code :-).  the templates in expression encoder provide very interesting stub code handling the simple and advanced media playback capabilities already for you.  if all you need is a simple mediaelement in your silverlight application, then sure, it's a bit heavy.  but if you are developing a media playback integration with end-user controls, you may want to consider it.  it provides all the simple play/pause/etc functionality, but also the glitz of volume slider handlers, time thumb handlers, fullscreen view, etc.  very slick.

anyhow, maybe you decide to go this route and create your killer player with your own xaml (you can see a screencast of this here).  you decide you are sick with cut/paste every time and using the stub and having to replace.  no problem, create your experience as a custom template!  here's how.

first, take a look at the template files in the expression encoder template folder (<installdir>\Microsoft Expression\Encoder 1.0\Templates\en).  you'll see all sorts of replacement code in there.  if you like all of the functionality, then don't change a thing (except your xaml).  if you have special code in your implementation then spend some more time looking at the replacement values and see what you have to modify.  for our purposes here, let's assume we are only modifying the xaml UI. 

create a new folder in the Templates\en (or your language) directory.  it doesn't matter what you name it here...this is not what shows up in the output options.  i've named mine 'TimHeuerSimple' just to be clean and, well simple.

then what i do (remember in this sample here we are only replacing the xaml ui) is copy the contents of a previous template (i use corporate silver) and put it in my new folder.  done.  now you have (or should) make three changes:

    1. edit the player.xaml file in the new folder to be your desired xaml.  should be a simple open, select all, paste, save operation for most.
    2. create a new preview image so the user can get a glimpse of the preview.  it doesn't have to be named preview.jpg, but as long as it is, you'll save yourself one more change :-).  the other preview images are 649x487 so i just stuck with those sizes as well.
    3. open the Default.html file.  look at line 2.  here is where you'll change to the template name you want the user to see.  your templates are always added to the bottom of the other template listings, so no need to get trickery here with the name.  NOTE: if you created your preview image as something other than 'preview.jpg' line 3 in this file is also where you will change the pointer to that preview.

boom, you are done.  now next time you start expression encoder, you'll see your template as an output option:

there you have it...now when you want to encode your media and have the output into your custom player (or perhaps a corporate/departmental standard look and functionality) you have it.

hope this helps!


Gravatar
9/11/2007 11:15 PM | # re: expression encoder and custom templates
hi, cool, but where is the screencast? looks like the link is missing?
9/12/2007 9:11 PM | # re: expression encoder and custom templates
Joe: no screencast on this one, just a blog post...were you referring to my other ones? you can see them in the podcast feed on the left of my blog
9/14/2007 7:36 AM | # re: expression encoder and custom templates
Great info, was hoping you could help a bit. I used the encoder, created what I wanted, and then tried to move the files into another project(needed to dynamically call diff videos). When I include the MicrosoftAjax.js file, it gives an error about Sys_application. Without it, it give an error about not able to find Eme and Type. I have other ajax on the page and am using the scriptmanager for that. Any help would be appreciated.
9/14/2007 10:43 AM | # re: expression encoder and custom templates
ernie: good catch, added what i did here: http://timheuer.com/blog/archive/2007/09/14/expression-encoder-and-aspnet-ajax.aspx
11/26/2007 4:57 PM | # re: expression encoder and custom templates
felixthehat: how is your png file being used in your template? is it in the default.html referencing?
6/30/2008 2:01 PM | # re: expression encoder and custom templates
how can i add manage template (c#) to template
I created Wpfcontorl that inherit form mediaplyer but i cant see the template :(
3/2/2010 12:31 PM | # re: expression encoder and custom templates
Hello Tim.. I have a quick question.. What if my project is in vb and I want to add this silverlight player component that seems to be csharp?
3/2/2010 1:11 PM | # re: expression encoder and custom templates
Rich -- you can reference any compiled control in your project, regardless of language.

 
Please add 2 and 7 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.