Developing custom modules to add Provider plugins to Embedded Media Field (2.x)
Here is a very brief introduction to developing a custom provider module for Embedded Media Field 2.x.
For further information, see http://groups.drupal.org/node/19876 for a video of a Drupal Dojo session in which Aaron Winborn explains how Embedded Media Field works, and demonstrates creating a provider module both for a site that has an API (Hulu.com) and one that does not (Whitehouse.gov).
Also, look at the file contrib/emvideo/providers/example.inc.txt under your install of the emfield module to see fairly extensive inline documentation of the functions in a provider include field for Emfield (which are various hooks that are used by the Emfield API to render media from the given provider).
The following steps to creating your custom provider module presume you have access to the command line and are comfortable using it.
- Download a provider module. For example,
drush dl media_vimeo - Copy its code into a new directory. For example,
cp -R media_vimeo media_provider(where provider is the name of the provider, and you are already in the sites/all/modules directory for your site). - Rename all the files in the directory accordingly. (TODO: Write an elegant one-liner that does the recursive renaming of the files...probably something with find & xargs.)
- Recursively replace the name of the provider in all files. The following one-liner does this:
find . -type f -exec perl -i -pe 's/vimeo/provider/g; s/Vimeo/Provider/g; s/VIMEO/Provider/g' {} \;(credit to acklen on #drupal IRC) - Delete artifacts of the Drupal packaging script in media_provider.info.
- Modify the hooks in your new provider module's media_provider.module & includes/providers/provider.inc to work with your provider's API. (More details to come. Some of these hooks are essentially the same as they were in 1.x.)
- Remove admin and theme include files that are not relevant for your provider. (More details to come.)
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion