Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To recreate: in a custom module pass videos to the theme function to render a proper HTML5 video with fallthrough to flash.
$items = array(
'mp4' => $node->field_video_h264[0],
'ogg' => $node->field_video_ogg[0],
'thumbnail' => $node->field_video_thumbnail[0],
);
$attributes = array(
'width' => 420,
'height' => 290,
'playlist' => TRUE,
);
$content = theme('videojs', $items, 'videojs-playerid', $attributes);
The resulting code rendered on the page will have something like this following:
<video>
<source src="/path/to/file/on/server/video.mp4" type="video/mp4; codecs='avc1.42E01E, mp4a.40.2'">
<source src="/path/to/file/on/server/video.ogv" type="video/ogg; codec='theora, vorbis'">
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
<object width="420" height="290" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf">
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf">
<param name="allowfullscreen" value="true">
<param name="flashvars" value="config={'playlist': [ 'http://sitename.com/image.jpg', {'url': 'http://sitename.com/system/files/videos/video.mp4', 'autoPlay':false, 'autoBuffering':true} ]}">
<embed id="flash-videojs-videojs-playerid" name="flash-videojs-videojs-playerid" src="http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf" width="420" height="290" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" flashvars="config={'playlist': [ 'http://sitename.com/system/files/video-thumbnail.jpg', {'url': 'http://sitename.com/system/files/videos/video.mp4', 'autoPlay':false, 'autoBuffering':true} ]}">
<!-- Image Fallback. Typically the same as the poster image. -->
<img src="http://sitename.com/system/files/video-thumbnail.jpg" width="420" height="290" alt="Poster Image" title="No video playback capabilities.">
</object>
</video>
Comment | File | Size | Author |
---|---|---|---|
#1 | bad-urls-1162846-1.patch | 1008 bytes | lliss |
Comments
Comment #1
lliss CreditAttribution: lliss commentedThe following patch seems to fix it. Looks like it was partially in place in the module but somehow got commented out.
Comment #2
tim.plunkettYeah, it definitely was strange with that commented out line. This patch looks good, and works well.
Comment #3
smira CreditAttribution: smira commentedi'm getting the following error
"warning: array_merge() [function.array-merge]: Argument #2 is not an array in /usr/share/nginx/icyou/sites/all/modules/videojs/includes/videojs.theme.inc on line 145."
on the video node with no video player present.
it looks like the error message points to the same line you patched but it doesn't seem to fix the issue.
Is this the same issue or am i way off?
thank you,
-miro
Comment #4
VM CreditAttribution: VM commentedtitle alter
Comment #5
VM CreditAttribution: VM commentedmoving to -dev as well
Comment #6
aethr CreditAttribution: aethr commentedMight want to consider checking for absolute URLs when using file_create_url().
See #1282232: Use of file_create_path($path) breaks serving videos from external sites
Comment #7
Jorrit CreditAttribution: Jorrit commentedFixed in 6.x-1.x, please test this in tomorrows -dev release.