summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filefield_meta/filefield_meta.install75
-rw-r--r--filefield_meta/filefield_meta.module25
2 files changed, 100 insertions, 0 deletions
diff --git a/filefield_meta/filefield_meta.install b/filefield_meta/filefield_meta.install
index 03f1561..c879163 100644
--- a/filefield_meta/filefield_meta.install
+++ b/filefield_meta/filefield_meta.install
@@ -48,9 +48,84 @@ function filefield_meta_schema() {
'size' => 'normal',
'not null' => FALSE,
),
+ 'audio_format' => array(
+ 'description' => t('The audio format.'),
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'audio_sample_rate' => array(
+ 'description' => t('The sample rate of the audio.'),
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'audio_channel_mode' => array(
+ 'description' => t('The number of channels in the audio, by name.'),
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'audio_bitrate' => array(
+ 'description' => t('The audio bitrate.'),
+ 'type' => 'float',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'audio_bitrate_mode' => array(
+ 'description' => t('The kind of audio bitrate.'),
+ 'type' => 'varchar',
+ 'length' => 4,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
),
'primary key' => array('fid'),
);
return $schema;
}
+
+function filefield_meta_update_1() {
+ $ret = array();
+ db_add_field($ret, 'filefield_meta', 'audio_format', array(
+ 'description' => t('The audio format.'),
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+ db_add_field($ret, 'filefield_meta', 'audio_sample_rate', array(
+ 'description' => t('The sample rate of the audio.'),
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ));
+ db_add_field($ret, 'filefield_meta', 'audio_channel_mode', array(
+ 'description' => t('The number of channels in the audio, by name.'),
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+ db_add_field($ret, 'filefield_meta', 'audio_bitrate', array(
+ 'description' => t('The audio bitrate.'),
+ 'type' => 'float',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ));
+ db_add_field($ret, 'filefield_meta', 'audio_bitrate_mode', array(
+ 'description' => t('The kind of audio bitrate.'),
+ 'type' => 'varchar',
+ 'length' => 4,
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+ return $ret;
+} \ No newline at end of file
diff --git a/filefield_meta/filefield_meta.module b/filefield_meta/filefield_meta.module
index c2ac5dd..ae21de1 100644
--- a/filefield_meta/filefield_meta.module
+++ b/filefield_meta/filefield_meta.module
@@ -13,6 +13,12 @@ function filefield_meta_theme() {
'filefield_meta_duration' => array(
'arguments' => array('duration' => NULL),
),
+ 'filefield_meta_samplerate' => array(
+ 'arguments' => array('samplerate' => NULL),
+ ),
+ 'filefield_meta_bitrate' => array(
+ 'arguments' => array('bitrate' => NULL),
+ ),
);
}
@@ -68,6 +74,11 @@ function filefield_meta(&$file) {
}
}
$file->data['duration'] = $info['playtime_seconds'];
+ $file->data['audio_format'] = $info['audio']['dataformat']; //e.g. mp3
+ $file->data['audio_sample_rate'] = $info['audio']['sample_rate']; //e.g. 44100
+ $file->data['audio_channel_mode'] = $info['audio']['channelmode']; // e.g. mono
+ $file->data['audio_bitrate'] = $info['audio']['bitrate']; //e.g. 64000
+ $file->data['audio_bitrate_mode'] = $info['audio']['bitrate_mode']; //e.g. cbr
};
/**
@@ -85,3 +96,17 @@ function theme_filefield_meta_duration($duration) {
return intval($minutes).':'.str_pad($seconds, 2, 0, STR_PAD_LEFT);
}
+
+/**
+ * Formats audio sample rate.
+ */
+function theme_filefield_meta_samplerate($samplerate) {
+ return sprintf("%.1f kHz", $samplerate/1000);
+}
+
+/**
+ * Formats audio bit rate.
+ */
+function theme_filefield_meta_bitrate($bitrate) {
+ return sprintf("%d Kbps", $bitrate/1000);
+}