Hi,

I'm using getID3 but cannot figure out a way to only allow the upload of files that are of a certain length say: up to 10 seconds long. If it is longer than 10 seconds then do not allow the node to be saved.

Is this possible and if so, please help point me in the correct direction.

p.s. i can get the songs length from getID3 but do not know how to refuse a long song.

Comments

tamerzg’s picture

No this is currently not possible in audiofield. It would certainly be interesting option and if somebody is willing to implement it I ll be glad to commit.

matteblacke’s picture

I have a very limited knowledge of Module design so i really don't think i will be the best person to implement it. I have tried to implement another module which on the form validation allows an mp3 up to a certain length but when enabled it stops the user logging in.

Maybe you can give me an idea of what i am doing wrong?

<?php
// $Id$
/**
* @file
* Simple module to run some custom validation on a story node
*/
 
/*
* Implementation of hook_form_alter()
*
*/
function tise_helper_form_alter(&$form, $form_state, $form_id) {

$form['#validate'] = array('_tise_helper_new_post_form_validate');

return $form;
}


 
/*
* Validates the story node form, and throws an error to the user if validation fails
*
*/
function _tise_helper_new_post_form_validate($form, &$form_state) {

$long = $form_state['values']['field_post_audio_upload'][0]['data']['duration'];

if($long > 11.0)
{
form_set_error('field_post_audio_upload', t('Song Length must be less than 10 seconds! Your song is '.$long.' seconds long'));
}
 
}
Anonymous’s picture

Issue summary: View changes

D6 module deprecated. Issue will be closed.

Anonymous’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.