'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
'filefield_meta_duration' => array(
'arguments' => array('duration' => NULL),
),
+ 'filefield_meta_samplerate' => array(
+ 'arguments' => array('samplerate' => NULL),
+ ),
+ 'filefield_meta_bitrate' => array(
+ 'arguments' => array('bitrate' => NULL),
+ ),
);
}
}
}
$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
};
/**
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);
+}