Has anybody tried to get Captions to work?

How can this be done?

http://flowplayer.org/plugins/flash/captions.html

Comments

justingeeslin’s picture

I've had some success at this.
I'm using the Flowplayer plugins: Captions, and Content.

I've added the following lines to the .module in function flowplayer_add().
No sure if this is the right place for it.

This loads up a Subrip file (.srt) from the modules directory.

    $config['clip']['captionUrl'] = drupal_get_path('module', 'flowplayer') . '/buffalo.srt';
    $config['plugins']['captions']['url'] = drupal_get_path('module', 'flowplayer') .'/flowplayer/flowplayer.captions.swf';
    $config['plugins']['captions']['captionTarget'] = 'content';
    $config['plugins']['content']['url'] = drupal_get_path('module', 'flowplayer') .'/flowplayer/flowplayer.content.swf';
    $config['plugins']['content']['bottom'] = 15;
    $config['plugins']['content']['height'] = 40;
    $config['plugins']['content']['backgroundColor'] = 'transparent';
    $config['plugins']['content']['backgroundGradient'] = 'none';
    $config['plugins']['content']['border'] = 0;
    $config['plugins']['content']['textDecoration'] = 'outline';
    $config['plugins']['content']['style']['body']['fontSize'] = 14;
    $config['plugins']['content']['style']['body']['fontFamily'] = 'Arial';
    $config['plugins']['content']['style']['body']['fontWeight'] = 'bold';
    $config['plugins']['content']['style']['body']['textAlign'] = 'center';
    $config['plugins']['content']['style']['body']['color'] = '#333333';

This will load up the same captions file for every video. That's progress.

I'd like to have a captions file for each video. In a filefield perhaps.
How can I alter the player per node?

justingeeslin’s picture

Is there any way to add captions to the player per node?

The code above adds captions (the same captions) to all nodes.

mlecha’s picture

Hi,

I don't think that you'd want to modify the flowplayer.module as it will get overwritten when you upgrade the module.

I'd suggest taking a look at this video. The solutions are a bit generic, but he's implementing the flowplayer_add() function in your template's preprocess function located in template.php.
http://gotdrupal.com/videos/drupal-flowplayer

Then look at Comment #4 at http://drupal.org/node/808708 for some code examples and additional explanation.

I've implemented a custom video content type (in Drupal 7, or CCK in v6) with path, width and height fields. I access the content of those fields in my preprocess function so that all the each video node loads its own video.

I've having issues getting the rtmp streaming plugin to work. But the rest is good.
http://drupal.org/node/1137710

I'd like to know how to access some debugging/error info from Flowplayer.

justingeeslin’s picture

Right. I didn't intend on leaving the module modified. I was just doing everything I knew how to do.

The module though should consider adding the captions feature.

To get Captions to work, i modified my template file for my video content type. node-video.tpl.php
The video content type has a file field for a captions file. field_captionfile

  <div class="content">
   <a href="<?php print $node->field_featuredvideo[0]['filepath'] ?>" id="player" class="flowplayer"></a>
   <?php
        if ($node->field_captionfile[0]['filepath'] != "") {
           flowplayer_add('#player', array(
                'clip' => array(
                  'captionUrl' => $node->field_captionfile[0]['filepath'],
                  'autoPlay' => 0,
                  'autoBuffering' => true,
                ),
                'plugins' => array(
                    'captions' => array(
                        'url' => drupal_get_path('module', 'flowplayer') .'/flowplayer/flowplayer.captions.swf',
                        'captionTarget' => 'content',
                    ),
                    'content' => array(
                      'url' => drupal_get_path('module', 'flowplayer') .'/flowplayer/flowplayer.content.swf',
                      'bottom' => 30,
                      'height' => 40,
                      'backgroundColor' => 'transparent',
                      'backgroundGradient' => 'none',
                      'textDecoration' => 'outline',
                      'border' => 0,
                      'style' => array(
                          'body' => array(
                              'fontSize' => 14,
                              'fontFamily' => 'Arial',
                              'fontWeight' => 'bold',
                              'fontAlign' => 'center',
                              'color' => '#0087de',
                          ),
                      ),
                    ),
                ),
              ));
        }
        else {
            flowplayer_add('#player', array(
                'clip' => array(
                  'autoPlay' => 0,
                  'autoBuffering' => true,
                ),
              ));
        }
    ?>
    <?php print $content; ?>
  </div> 

I put the above code in the node-video.tpl.php.
It check to see if there is a captions file. If there is a captions file, it loads the Captions plugin and the caption file in field_captionfile. If there is Not a captions file, it just loads the player as normal.

I removed my modifications to the module. I only needed to modify this file. I exclude my video field (field_featruedvideo) from $content as well.

Note: The flowplayer.captions.swf referenced in this code is not included in the module on

Works like a dream.
Writing the xml caption files not so easy.. :)

Thanks all!

firecentaur’s picture

I found a great post about pulling captions from the database... its a non-drupal site, so trying to drupal-ize..
he generates xml files on the fly, using fancy rewrite rules and a php file...

http://www.halgatewood.com/subtitles-with-flowplayer/

fletchgqc’s picture

Version: 6.x-1.0-beta1 » 7.x-1.0-alpha1

Thanks for the help with how to get it going. I noticed one critical problem though - the content plugin (required for captions) is missing from the module. Could someone please add this?

I just downloaded it manually but of course as it stands, if I upgrade the module I'll lose it.

I've changed the version of this issue to 7.x because that's what I'm using and that's what it's missing from. I guess it's missing from all versions.

By the way for the url argument flowplayer by default searches in the same directory as the flowplayer.swf. So instead of 'url' => drupal_get_path('module', 'flowplayer') .'/flowplayer/flowplayer.captions.swf',, just do 'url' => 'flowplayer.captions.swf',

fletchgqc’s picture

Title: Captions » Captions: Add Flowplayer Content Plugin (+ Captions howto)

Changing title.