Community Documentation

Developing custom modules to add Provider plugins to Embedded Media Field (2.x)

Last updated January 14, 2011. Created by EvanDonovan on January 14, 2011.
Log in to edit this page.

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.

  1. Download a provider module. For example, drush dl media_vimeo
  2. 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).
  3. 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.)
  4. 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)
  5. Delete artifacts of the Drupal packaging script in media_provider.info.
  6. 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.)
  7. Remove admin and theme include files that are not relevant for your provider. (More details to come.)

Comments

example.inc.txt

The example.inc.txt mentioned is now a part of the Media: Video Flotsam module.

Also, the video session is no longer available, the dimdim links no longer work on the linked page.

Page status

About this page

Drupal version
Drupal 6.x
Audience
Programmers

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here