I'm building a site that has 46+ videos associated with it. I'm using Mediaelement.js. Each video has at least two language .srt files, a .vtt chapter marker file and two video sources, mp4 and WebM.

My project mananger says, "do it how ever is easier for you."

Part of me is tempted to upload all the files, then just copy-pasta the mediaelement code and change the file names. But this is laborous, time-consumming and prone to error.

As I'm writing this I think that I need to have a content type that has 5 or more "file upload" fields. How do I use the media module to my advantage?

1 Answer 1


Here's the solution I'm working on:

new Content Type: Video.

This content type has file fields for each file, two video type, up to 10 closed caption files, and chapter markers.

Then I add a node--video.tpl.php Within the node template I'm then doing this:

 $mp4 = ltrim ($node->field_mp4_video[und][0][uri], 'public:/');
 $webm = ltrim ($node->field_webm_video[und][0][uri], 'public:/');
 $vtt = ltrim ($node->field_chapter_markers[und][0][uri], 'public:/');
 $encc = ltrim($node ->field_closed_captions[und][0][uri], 'public:/');
 $escc = ltrim($node ->field_closed_captions[und][1][uri], 'public:/');

ltrim trims the public:/ from the front of the string and printing that inside the video element:

<video width="100%" height="100%" style="width:100%; height=100%;" id="player2" controls="controls" >
  <source src="../sites/default/files/<?php print $mp4 ?>" type="video/mp4">
  <source src="../sites/default/files/<?php print $webm ?>" type="video/webm">
  <track kind="subtitles" src="../sites/default/files/<?php print $encc ?>"  srclang="en" />
  <track kind="subtitles" src="../sites/default/files/<?php print $escc ?>"  srclang="es" />
  <track kind="chapters" src="../sites/default/files/<?php print $vtt ?>"  />
  <p>Unsupported in this browser.</p>

The un-solved issue is if there's more than the English and Spanish closed-captions. Certainly solvable, but probably outside of the scope of the project as currently budgeted.

Also, Drupal is throwing an error Notice: Use of undefined constant.... I'll tackle that in a separate question.

  • In looking at the mediaelementjs module I realize I'm duplicating the functionality within the module. Now if only someone described how to actually use the module ...
    – icicleking
    Commented May 13, 2015 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.