Creating a custom Media Engine allows you to use new media software to perform Media
Actions on files in ADAM, such as creating previews, extracting textual content
or reading XMP metadata. The provider model in ADAM allows you to easily plug this
custom provider in together with the built-in Media Engines.
Basic information about how to create a custom MediaEngine can be found in the Adam
Developer Guide. If you are developing your first MediaEngine you should definitely
take a look at our documentation.
The actual purpose of this blog post is to give a few hints and tricks when creating
your own MediaEngine. Some frequently asked questions or things to make your coding
process easier.
Return value
The return value of the Run method is a boolean. Remember the following rules:
- The requested media action was executed successfully: return true.
- The requested media action failed during the process: throw an exception.
- The requested media action is not supported in your MediaEngine: return
false.
Switch Case
Use a Switch Case statement in the 'Run' method for processing each MediaAction.
e.g.
| C# |
1
2
3
4
5
6
7
8
9
10
11
|
switch (action.Id)
{
case CreatePreviewImagesMediaAction.ActionId:
return RunCreatePreviewImagesAction((CreatePreviewImagesMediaAction)action);
case ReadContentMediaAction.ActionId:
return RunReadContentAction((ReadContentMediaAction)action);
default:
return false;
}
|
Disposing
A frequent mistake is to think that no private Fields can be used in your engine.
It is important to know that the 'Run' method is executed repeatedly for every available
MediaAction, but the 'Dispose' method is only executed once, after the engine is
done processing.
That's why you can safely store some information in private fields and you do not
need to reload or reassign values for each time 'Run' is executed.
MediaEngine Exception
When creating your engine a 'MediaEngineException' is available. You can throw this
exception for an appropriate error that occured during processing.
Getting it done
When you When you are finished coding you only need to register and activate your
custom provider into ADAM. Detailed information on how to do this can be found in
the Adam Developer Guide.
After this your engine is ready to use. Remember that it is also possible to test
it in the Adam MediaEngineTester utility. A blog post about how to use this utility
can be found here.