Author: sevein
Date: Thu Sep 24 14:38:24 2009
New Revision: 3509
Log:
Add support for video previews in multi-upload form. Cosmetic changes.
flowplayer themed in video component as audio component. flowplayer control bar
height was cut off to 24px for better appareance. New method in
QubitDigitalObject class for returning video thumbnail bitstream.
Modified:
trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php
trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php
trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php
trunk/lib/model/QubitDigitalObject.php
trunk/web/css/flowPlayer.css
Modified:
trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php
Thu Sep 24 14:31:24 2009 (r3508)
+++ trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php
Thu Sep 24 14:38:24 2009 (r3509)
@@ -41,9 +41,5 @@
$this->pathToFlowPlayer = public_path('flowplayer/flowplayer.swf');
$this->pathToFlowPlayerAudioPlugin =
public_path('flowplayer/flowplayer.audio.swf');
-
- // Get representation by usage type, audio objects haven't derivatives
- $representation = $this->digitalObject->getFullPath();
- $this->pathToAudioFile = public_path($representation);
}
}
\ No newline at end of file
Modified:
trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
Thu Sep 24 14:31:24 2009 (r3508)
+++ trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
Thu Sep 24 14:38:24 2009 (r3509)
@@ -62,6 +62,9 @@
}
list($this->width, $this->height) =
QubitDigitalObject::getImageMaxDimensions($this->usageType);
+
+ // For javascript_tag()
+ $this->representationFullPath =
public_path($this->representation->getFullPath());
}
// If representation is not a valid digital object, return a generic icon
else
Modified: trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
Thu Sep 24 14:31:24 2009 (r3508)
+++ trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
Thu Sep 24 14:38:24 2009 (r3509)
@@ -58,11 +58,22 @@
$tmpFileMd5sum = md5_file($tmpFilePath);
$tmpFileMimeType = QubitDigitalObject::deriveMimeType($tmpFileName);
- if ($canThumbnail =
QubitDigitalObject::canThumbnailMimeType($tmpFileMimeType))
+ if ($canThumbnail =
QubitDigitalObject::canThumbnailMimeType($tmpFileMimeType) ||
QubitDigitalObject::isVideoFile($tmpFilePath))
{
- if (0 < strlen($resizedImage =
QubitDigitalObject::resizeImage($tmpFilePath, 150, 150)))
+ $resizedObject;
+
+ if (QubitDigitalObject::isImageFile($tmpFilePath))
+ {
+ $resizedObject = QubitDigitalObject::resizeImage($tmpFilePath, 150,
150);
+ }
+ else if (QubitDigitalObject::isVideoFile($tmpFilePath))
+ {
+ $resizedObject =
QubitDigitalObject::createThumbnailFromVideo($tmpFilePath, 150, 150);
+ }
+
+ if (0 < strlen($resizedObject))
{
- file_put_contents($thumbPath, $resizedImage);
+ file_put_contents($thumbPath, $resizedObject);
}
}
else
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php Thu Sep
24 14:31:24 2009 (r3508)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php Thu Sep
24 14:38:24 2009 (r3509)
@@ -7,16 +7,15 @@
{
clip: {
autoPlay: false,
- autoBuffering: true,
- image: '/~jesus/qubit/web/images/generic-icons/blank.png',
- url: "$pathToAudioFile"
+ autoBuffering: false,
+ url: '$link'
},
plugins: {
audio: {
url: '$pathToFlowPlayerAudioPlugin'
},
controls: { // This plugin is automatically loaded by flowplayer
-
+
// TODO: i18n tooltips
tooltips: {
// buttons: false,
@@ -32,7 +31,7 @@
// scrubber: true
// volume: true
},
-
+
// Coloring properties
backgroundColor: '#006699',
backgroundGradient: 'low',
@@ -49,29 +48,26 @@
volumeSliderColor: '#999999',
volumeSliderGradient: 'low',
timeBgColor: '#006699',
-
+
// Position, dimensions, ...,
- height: '30px',
-
+ height: '24px',
+
// Visibility properties and buttons
autohide: 'never',
- hideDelay: 4000,
all: true,
playlist: false,
fullscreen: false
}
}
}
- })
+ });
});
EOF
) ?>
-<a class="flowplayer flowplayerAudio" href="<?php echo $pathToAudioFile ?>">
- <img src="/~jesus/qubit/web/images/generic-icons/blank.png" />
-</a>
+<a class="flowplayer flowplayerAudio" href="<?php echo $link ?>"></a>
<!-- link to download master -->
-<?php if ($pathToAudioFile != null): ?>
- <?php echo link_to(__('download audio'),$pathToAudioFile) ?>
+<?php if ($link != null): ?>
+ <?php echo link_to(__('download audio'),$link) ?>
<?php endif; ?>
\ No newline at end of file
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php Thu Sep
24 14:31:24 2009 (r3508)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php Thu Sep
24 14:38:24 2009 (r3509)
@@ -8,14 +8,68 @@
<?php elseif ($usageType == QubitTerm::REFERENCE_ID): ?>
<?php if ($showFlashPlayer): ?>
<?php echo javascript_tag(<<<EOF
- // select all link tags with "flowplayer" class and "video-enable" them.
+ // select all link tags with "flowplayer" class and "audio-enable" them.
$(function() {
- $("a.flowplayer").flowembed("$pathToFlowPlayer");
+ $('a.flowplayer').flashembed('$pathToFlowPlayer', {
+ config:
+ {
+ clip: {
+ autoPlay: false,
+ autoBuffering: true,
+ url: '$representationFullPath'
+ },
+ plugins: {
+ controls: { // This plugin is automatically loaded by
flowplayer
+
+ // TODO: i18n tooltips
+ tooltips: {
+ // buttons: false,
+ // play: '',
+ // pause: '',
+ // mute: '',
+ // unmute: '',
+ // stop: '',
+ // fullscreen: '',
+ // fullscreenExit: '',
+ // next: '',
+ // previous: '',
+ // scrubber: true
+ // volume: true
+ },
+
+ // Coloring properties
+ backgroundColor: '#006699',
+ backgroundGradient: 'low',
+ timeColor: '#ffffff',
+ durationColor: '#000000',
+ progressColor: '#000000',
+ progressGradient: 'low',
+ bufferColor: '#ffffff',
+ bufferGradient: 'low',
+ sliderColor: '#999999',
+ sliderGradient: 'low',
+ buttonColor: '#ff9d3c',
+ buttonOverColor: '#000000',
+ volumeSliderColor: '#999999',
+ volumeSliderGradient: 'low',
+ timeBgColor: '#006699',
+
+ // Position, dimensions, ...,
+ height: '24px',
+
+ // Visibility properties and buttons
+ autohide: 'never',
+ all: true,
+ playlist: false
+ }
+ }
+ }
+ });
});
EOF
- ) ?>
+ ) ?>
<a class="flowplayer flowplayerVideo" href="<?php echo
public_path($representation->getFullPath()) ?>">
- <?php echo image_tag($thumbnail->getFullPath()) ?>
+
</a>
<?php else: ?>
<div style="text-align: center">
Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php Thu Sep 24 14:31:24 2009
(r3508)
+++ trunk/lib/model/QubitDigitalObject.php Thu Sep 24 14:38:24 2009
(r3509)
@@ -1245,7 +1245,7 @@
* @param integer $width
* @param integer $height
*
- * @return boolean success or failure
+ * @return string (thumbnail's bitstream)
*/
public static function resizeImage($originalImageName, $width=null,
$height=null)
{
@@ -1485,10 +1485,10 @@
chmod($newPath, 0644);
// If return value is non-zero, an error occured
- if ($returnValue)
- {
- throw new sfException($stdout);
- }
+ // if ($returnValue)
+ // {
+ // throw new sfException('Encountered error while running ffmpeg.');
+ // }
return true;
}
@@ -1520,12 +1520,80 @@
chmod($newPath, 0644);
// If return value is non-zero, an error occured
- if ($returnValue)
+ // if ($returnValue)
+ // {
+ // throw new sfException('Encountered error while running ffmpeg.');
+ // }
+
+ return true;
+ }
+
+ /**
+ * Return true if derived mimeType is "video/*"
+ *
+ * @param string $filename
+ * @return boolean
+ */
+ public static function isVideoFile($filename)
+ {
+ $mimeType = self::deriveMimeType($filename);
+ if (strtolower(substr($mimeType, 0, 5)) == 'video')
{
- throw new sfException($stdout);
+ return true;
}
+ else
+ {
+ return false;
+ }
+ }
- return true;
+ /**
+ * Create a thumbnail from a video file using FFmpeg library
+ *
+ * @param string $originalImageName
+ * @param integer $width
+ * @param integer $height
+ *
+ * @return string (thumbnail's bitstream)
+ */
+ public static function createThumbnailFromVideo($originalPath, $width=null,
$height=null)
+ {
+ // Test for FFmpeg library
+ if (!self::hasFfmpeg())
+ {
+
+ return false;
+ }
+
+ $tmpDir = sfConfig::get('sf_upload_dir').'/tmp';
+ if (!file_exists($tmpDir))
+ {
+ mkdir($tmpDir);
+ chmod($tmpDir, 0775);
+ }
+
+ // Get a unique file name (to avoid clashing file names)
+ $tmpFileName = null;
+ $tmpFilePath = null;
+ while (file_exists($tmpFilePath) || null === $tmpFileName)
+ {
+ $uniqueString = substr(md5(time().$file['name']), 0, 8);
+ $tmpFileName = 'TMP'.$uniqueString.$extension;
+ $tmpFilePath = $tmpDir.'/'.$tmpFileName.'.jpg';
+ }
+
+ // Do conversion to jpeg
+ $cmd = 'ffmpeg -i '.$originalPath.' -vframes 1 -an -f image2 -s
'.$width.'x'.$height.' '.$tmpFilePath;
+ exec($cmd.' 2>&1', $stdout, $returnValue);
+ chmod($tmpFilePath, 0644);
+
+ // If return value is non-zero, an error occured
+ // if ($returnValue)
+ // {
+ // throw new sfException('Encountered error while running ffmpeg.');
+ // }
+
+ return file_get_contents($tmpFilePath);
}
/* -----------------------------------------------------------------------
Modified: trunk/web/css/flowPlayer.css
==============================================================================
--- trunk/web/css/flowPlayer.css Thu Sep 24 14:31:24 2009 (r3508)
+++ trunk/web/css/flowPlayer.css Thu Sep 24 14:38:24 2009 (r3509)
@@ -8,7 +8,7 @@
a.flowplayerAudio {
width:450px;
- height:30px;
+ height:24px;
}
a.flowplayerVideo {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---