Last updated March 23, 2011. Created by blackdog on March 15, 2009.
Edited by marcvangend. Log in to edit this page.
Video Filter is a highly flexible and easy extendable filter module to embed any type of video in your site using a simple tag. Other modules can add video sites/formats (called codecs) using an easy plug-in architecture.
Installation
Enable the module on the modules page.
Drupal 7:
Go to admin/config/content/formats and configure the text format(s) that should
be allowed to use this filter. Check the box to enable Video Filter and save.
Some simple settings are available if you configure the text format. There you
can change the default size and auto play settings.
Drupal 5 & 6:
Go to admin/settings/filters and configure the input format(s) that should
be allowed to use this filter. Check the box to enable Video Filter and save.
Some simple settings are available if you configure the input format.
There you can change the default size and auto play settings.
All:
Make sure that Video Filter is processed before "Convert URLs to links".
You can do this by dragging and dropping Video Filter to the top of the
processing order list. Do this even if it's allready on top, just to make sure!
If you're using the "Limit allowed HTML tags" filter, make sure Video Filter is processed after that filter.
To enable WYSIWYG support, go to the WYSIWYG settings for each input format and enable the Video Filter button.
Usage
Single video: [video:url]
This will output the video using the default settings.
Random video from multiple URL's: [video:url,url,url]
This will output one of the specified videos each time.
You can also set some parameters in the call:
[video:url width:X height:Y align:left/right autoplay:1/0]
This will override the default settings for this video.
Developers
This module calls hook_codec_info(), so you can add your own codecs.
Example:
<?php
function MODULE_codec_info() {
$codecs = array();
// You can offer multiple video formats in one module.
$codecs['youtube'] = array(
// Will be used some day in user information.
'name' => t('YouTube'),
// The callback that will output the right embed code.
'callback' => 'MODULE_youtube',
// Regexp can be an array. $video['codec']['delta'] will be set to the key.
'regexp' => '/youtube\.com\/watch\?v=([a-z0-9]+)/i',
// Ratio for resizing within user-given width and height (ratio = width / height)
'ratio' => 425 / 355,
);
return $codecs;
}
?>And this will be your callback function:
<?php
function MODULE_youtube($video) {
// $video contains the video URL in source, the codec (as above) and also [code][matches] with the result of the regexp and [codec][delta] with the key of the matched regexp.
$video['source'] = 'http://www.youtube.com/v/'.$video['codec']['matches'][1].($video['autoplay'] ? '&autoplay=1' : '');
// Outputs a general <object...> for embedding flash players. Needs width, height, source and optionally align (left or right) and params (a list of <param...> attributes)
return video_filter_flash($video);
}
?>
Comments
Brightcove
I wrote a codec for Brightcove if anyone needs it:
$codecs['brightcove'] = array('name' => t('Brightcove'),
'sample_url' => 'http://link.brightcove.com/services/player/bcpid1077328347001?bctid=10734535994001',
'callback' => 'video_filter_brightcove',
'regexp' => '/link\.brightcove\.com\/services\/player\/([a-z0-9\-_]+).*bctid=([a-z0-9]+)/i',
'ratio' => 425 / 355,
);
I have a callback function name video_filter_brightcove, but it could use a lil more finesse, ill post a link to it on my site after I get it done., the above should get you started,
$video['codec']['matches'][2]is the video id, and$video['codec']['matches'][1]would be the playerid.Need some Drupal consulting or custom themes ? rofsky.com
How dows one add the codec?
Is this something basic or one of those "if I have to ask..."
Thanks
RTMP streaming from Adobe Flash Media server
Here's an example of integrating an Adobe Flash Media server.
Create a custom module with the following code:
function flashmedia_video_filter_codec_info() {
$codecs['flashmedia'] = array(
'name' => t('Flash Media Server'),
'sample_url' => 'rtmp://flash.example.com/subdir/subdir/samplevideo.flv',
'callback' => 'flashmedia_video_filter_flashmedia',
'regexp' => '/flash\.example\.com\/subdir\/subdir\/([a-zA-Z0-9]+)/',
'ratio' => 480 / 360,
);
return $codecs;
}
function flashmedia_video_filter_flashmedia($video) {
$video['source'] = 'http://example.com/sites/all/libraries/mediaplayer/player.swf';
$params = array(
'allowscriptaccess' => 'always',
);
$params['flashvars'] = 'file=' . urlencode('/' . $video['codec']['matches'][1]);
$params['flashvars'] .= '&streamer=' . urlencode('rtmp://flash.example.com/subdir/subdir/');
$params['flashvars'] .= '&type=rtmp';
$params['flashvars'] .= '&width=' . $video['width'] ;
$params['flashvars'] .= '&height=' . $video['height'] ;
$params['flashvars'] .= '&autostart=false';
return video_filter_flash($video, $params);
}
Doug Gough
313 Web Development Studio