aboutsummaryrefslogtreecommitdiff
path: root/video.theme.inc
diff options
context:
space:
mode:
authorHeshan <heshan@heidisoft.com>2011-04-06 21:47:46 +0530
committerHeshan <heshan@heidisoft.com>2011-04-06 21:47:46 +0530
commit0ce24fea04b8b571ef887d184a7f8cdeca2d4c4a (patch)
treed07484b2f7e7de07fe2fec0a27198a6857bc629f /video.theme.inc
parent33aed9a2bc33078ffd2ba46d2e77ac78de187512 (diff)
downloadvideo-0ce24fea04b8b571ef887d184a7f8cdeca2d4c4a.tar.gz
video-0ce24fea04b8b571ef887d184a7f8cdeca2d4c4a.tar.bz2
#1092668 by anglo VideoJS player
Diffstat (limited to 'video.theme.inc')
-rw-r--r--video.theme.inc118
1 files changed, 75 insertions, 43 deletions
diff --git a/video.theme.inc b/video.theme.inc
index 41ab5e0..c5b1d7e 100644
--- a/video.theme.inc
+++ b/video.theme.inc
@@ -62,11 +62,17 @@ function theme_video($variables) {
$defaults = video_video_extensions();
$theme_function = variable_get('video_extension_' . $video->player, $defaults[$video->player]);
- // Lets do some special handling for our flv files to accomdate multiple players.
- if ($theme_function == 'video_play_flv') {
- return theme('video_flv', array('video' => $video, 'themed_output' => $themed_output));
- } else {
- return theme($theme_function, array('video' => $video, 'themed_output' => $themed_output));
+ // Lets do some special handling for our flv files, HTML5 to accomdate multiple players.
+ switch ($theme_function) {
+ case 'video_play_flv':
+ return theme('video_flv', array('video' => $video, 'themed_output' => $themed_output));
+ break;
+ case 'video_play_html5':
+ return theme('video_html5', array('video' => $video, 'themed_output' => $themed_output));
+ break;
+ default:
+ return theme($theme_function, array('video' => $video, 'themed_output' => $themed_output));
+ break;
}
}
@@ -75,16 +81,16 @@ function theme_video($variables) {
*/
function theme_video_thumbnail($variables) {
- // Inside a view $variables may contain null data. In that case, just return.
+// Inside a view $variables may contain null data. In that case, just return.
if (empty($variables['item']['fid']))
return '<!-- File not found: ' . $variables['item']['fid'] . ' -->';
- //setup our thumbnail object
+//setup our thumbnail object
module_load_include('inc', 'video', '/includes/video_helper');
$video_helper = new video_helper;
- // @TODO : change the object to an array
+// @TODO : change the object to an array
$thumbnail = (array) $video_helper->thumbnail_object($variables);
- // return if no file path found for the video thumbnails and add log message
+// return if no file path found for the video thumbnails and add log message
if (empty($thumbnail['filepath'])) {
watchdog('video', 'Unable to find the video thumbnail for the %node.', array('%node' => $variables['entity']->title), WATCHDOG_ERROR);
return '<!-- File not found: ' . $thumbnail['filepath'] . ' -->';
@@ -93,7 +99,7 @@ function theme_video_thumbnail($variables) {
'path' => $thumbnail['filepath'],
'alt' => $thumbnail['alt'],
);
- // Do not output an empty 'title' attribute.
+// Do not output an empty 'title' attribute.
if (drupal_strlen($thumbnail['title']) > 0) {
$image['title'] = $thumbnail['title'];
}
@@ -138,9 +144,9 @@ function theme_video_thumb_style($variables) {
$style_name = $variables['style_name'];
$path = $variables['path'];
- // theme_image() can only honor the $getsize parameter with local file paths.
- // The derivative image is not created until it has been requested so the file
- // may not yet exist, in this case we just fallback to the URL.
+// theme_image() can only honor the $getsize parameter with local file paths.
+// The derivative image is not created until it has been requested so the file
+// may not yet exist, in this case we just fallback to the URL.
$style_path = image_style_path($style_name, $path);
if (!file_exists($style_path)) {
$style_path = image_style_url($style_name, $path);
@@ -169,40 +175,66 @@ function theme_video_conversion_failed() {
function theme_video_flv($variables) {
$video = $variables['video'];
- // set the video flash player
- // Moved to last to recheck incase we changed our extension above.
+// set the video flash player
+// Moved to last to recheck incase we changed our extension above.
$video->flash_player = variable_get('video_extension_' . $video->player . '_flash_player', '');
- if ($video->flash_player == 'swftools') {
- $options = array(
- 'params' => array(
- 'width' => $video->player_width,
- 'height' => $video->player_height,
- ),
- 'othervars' => array(
- //@todo: swftools bug, can't enable this until they fix their pathing for the images.
- 'image' => $video->thumbnail->swfthumb,
- ),
- );
- $themed_output = swf($video->files->{$video->player}->url, $options);
- } elseif ($video->flash_player == 'flowplayer') {
- // kjh: use a playlist to display the thumbnail if not auto playing
- if (isset($video->autoplay) && isset($video->thumbnail->url)) {
+ switch ($video->flash_player) {
+ case 'swftools':
$options = array(
- 'playlist' => array($video->thumbnail->url,
- array('url' => urlencode($video->files->{$video->player}->url),
+ 'params' => array(
+ 'width' => $video->player_width,
+ 'height' => $video->player_height,
+ ),
+ 'othervars' => array(
+ //@todo: swftools bug, can't enable this until they fix their pathing for the images.
+ 'image' => $video->thumbnail->swfthumb,
+ ),
+ );
+ $themed_output = swf($video->files->{$video->player}->url, $options);
+ break;
+ case 'flowplayer':
+ // kjh: use a playlist to display the thumbnail if not auto playing
+ if (isset($video->autoplay) && isset($video->thumbnail->url)) {
+ $options = array(
+ 'playlist' => array($video->thumbnail->url,
+ array('url' => urlencode($video->files->{$video->player}->url),
+ 'autoPlay' => $video->autoplay,
+ 'autoBuffering' => $video->autobuffering,
+ ),),);
+ } else {
+ $options = array(
+ 'clip' => array('url' => urlencode($video->files->{$video->player}->url),
'autoPlay' => $video->autoplay,
'autoBuffering' => $video->autobuffering,
- ),),);
- } else {
- $options = array(
- 'clip' => array('url' => urlencode($video->files->{$video->player}->url),
- 'autoPlay' => $video->autoplay,
- 'autoBuffering' => $video->autobuffering,
- ),);
- }
- $themed_output = theme('flowplayer', array('config' => $options, 'id' => 'flowplayer-' . $video->formatter, 'attributes' => array('style' => 'width:' . $video->player_width . 'px;height:' . ($video->player_height + 24) . 'px;')));
- } else {
- $themed_output = t('No flash player has been setup. ' . l(t('Please select a player to play Flash videos.'), 'admin/settings/video/players'));
+ ),);
+ }
+ $themed_output = theme('flowplayer', array('config' => $options, 'id' => 'flowplayer-' . $video->formatter, 'attributes' => array('style' => 'width:' . $video->player_width . 'px;height:' . ($video->player_height + 24) . 'px;')));
+ break;
+ default:
+ $themed_output = t('No flash player has been setup. ' . l(t('Please select a player to play Flash videos.'), 'admin/settings/video/players'));
+ break;
}
return theme('video_play_flv', array('video' => $video, 'themed_output' => $themed_output));
+}
+
+/**
+ * Theme wrapper for HTML5
+ */
+function theme_video_html5($variables) {
+ $themed_output = NULL;
+ $video = $variables['video'];
+ echo $video->html5_player = variable_get('video_extension_' . $video->player . '_html5_player', '');
+ switch ($video->html5_player) {
+ case 'video':
+ return theme('video_play_html5', array('video' => $video, 'themed_output' => $themed_output));
+ break;
+ case 'videojs':
+ $items = _video_object_to_array($video->files);
+ $items +=array('thumbnail' => (array) $video->thumbnail);
+ $attributes = array();
+ $attributes['width'] = $video->width;
+ $attributes['height'] = $video->height;
+ return theme('videojs', array('items' => $items, 'player_id' => 'video-' . $video->fid, 'attributes' => $attributes));
+ break;
+ }
} \ No newline at end of file