Diem plugins syndication

dmFlowPlayerPlugin

Allows to read video, sound and flash medias

The dmFlowPlayerPlugin allows to read video, audio and flash medias.
It packages a Diem front widget, and extends the £media capabilities.

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/ornicar/dmFlowPlayerPlugin.git plugins/dmFlowPlayerPlugin  
  • In config/ProjectConfiguration.class.php, add dmFlowPlayerPlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmFlowPlayerPlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony dm:setup  

Flow Player Widget

A new widget appears in the front application "Add" menu:

Drag & Drop it somewhere on the page, then upload a file or Drag & Drop a media from the MEDIAS panel.

Audio & Video

Media

Dimensions

You should specify both width and height in pixels. If you let them empty, an optimal size will be calculated based on the widget size.

Method

How the media will be scaled if its original size if different than the widget size.

Options

Play automatically

If checked, the media will be played immediately on page load.

Show controls

If checked, the player controls will be displayed.

Splash

An image to be displayed before the Video/Audio media is played.

Media

As usual, you can upload a file or Drag & drop a media from the right MEDIAS panel.

Alt

The image alt attribute. Usefull for accessibility and search engine optimization, as search engines don't index the video content.

Flash

Media

Dimensions

You should specify both width and height in pixels. If you let them empty, an optimal size will be calculated based on the widget size.

Config

Here you can freely add configuration to be passed to the flashembed objet.
See available configuration options on the flowplayer website.
The configuration must be in YAML format.
Example of valid configuration:

bgcolor: #000000  
wmode: opaque  
quality: high  

Vars

Here you can freely add flashvars to the flash object.
The flashvars must be in YAML format.
Example of valid flashvars:

variable1: value1  
array_var: [ val2, val3 ]  

_media

The _media template helper is extended and now allows to display video, audio and flash medias.

Audio & Video

Complete example

// display a video using all available options
 
echo _media('myvideo.flv')  
->size(300, 200) // resize to 300px width, 200px height  
->method('fit')  // available methods: fit, scale, half, orig  
->control(true)  // display the player controls  
->autoplay(true) // play the video on page load  
->splash(        // display a clickable image to launch the video  
  _media('intro.jpg')  
  ->alt('Click to start')  
);  

Other splash

The splash can be a £media, or just HTML code:
ple

// display a video usgin html splash
 
echo _media('myvideo.flv')  
->splash(        // display a clickable text to launch the video  
  _tag('div',  
    _tag('h3', 'Our nice video about penguins').  
    _tag('p', 'Click to start')  
  )  
);  

Flash

Complete example

// display a flash object all available options
 
echo _media('myflash.swf')  
->size(300, 200)      // resize to 300px width, 200px height  
->flashConfig(array(  // configure flash rendering  
  'bgcolor' => '#000000',  
  'wmode' => 'opaque',  
  'quality' => 'high'  
))  
->flashVars(array(    // pass flash vars  
  'variable1' => 'value1',  
  'array_var' => array( 'val2', 'val3')  
));  

See available configuration options on the flowplayer website.

Filter and modify flowplayer options

By listening a symfony event (dm_flow_player.filter_options), you can modify options sent to flowplayer:
apps/front/config/frontConfiguration.class.php

require_once(dm::getDir().'/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php');
 
class frontConfiguration extends dmFrontApplicationConfiguration  
{  
  public function configure()  
  {      
    $this->dispatcher->connect('dm_flow_player.filter_options', array($this, 'listenToFlowPlayerFilterOptionsEvent'));  
  }  
 
  public function listenToFlowPlayerFilterOptionsEvent(sfEvent $event, array $options)  
  {  
    // modify the options array  
    return $options;  
  }  
}  

The event contains a attributes parameter you can use to access all the dmMediaTag attributes:

$width = $event['attributes']['width'];

If a DmMedia is rendered, you can access its ID:

$mediaId = $event['media_id'];
  • altranoDecember 25, 2009 6:49 PM

    Great work

    the question is can i get external videos, sounds, etc.?

    like from YouTube, Google and someone?

    Thanks

  • Thibault DJanuary 23, 2010 7:20 PM

    Nope. This plugin is intended to display medias hosted on your own server.
    It's way more configurable than, let's say, a youtube player. And you're not dependant to an external site.
    But another plugin to handle external medias should be written, yes.

  • RonaldApril 21, 2010 3:11 PM

    Nice work guys..but i cant get the _media tag to display flash videos on my site. I created a module with the dmMedia class and with a video_id column to bind to my model Videos, but i cant display the flv with _media helper on my template.. please is there a solution for this? or is it a bug with flowplayerplugin?

Add a comment

dmFlowPlayerPlugin, created on December 25, 2009 by Thibault D, used by 731 projects

Fork Diem on GitHub