Upload Audio File Duration

nate
@nate
10 years ago
917 posts
I need to get the duration of an uploaded audio file. I am saving it and I see the size but no file_length.

This is how I am saving
jrCore_save_media_file('xtDistribLicense', 'distriblicense_upload_file', $_user['user_active_profile_id'], $_post['id']);

This is what gets saved
Quote:
distriblicense_upload_file_type - audio/mpeg
distriblicense_upload_file_time - 1427221647
distriblicense_upload_file_size - 1489351
distriblicense_upload_file_name - Demo_Track_One.mp3
distriblicense_upload_file_extension - mp3

How do I get the duration?
updated by @nate: 04/25/15 10:18:13PM
brian
@brian
10 years ago
10,149 posts
You want to use the jrCore_get_media_file_metadata() function - i.e.

$file = '/local/file.mp3';
jrCore_get_media_file_metadata($file, 'distriblicense');

Will return an array of meta data about the MP3 file, with "distriblicense" being the key prefix you want for the keys in the return array - i.e. "audio", etc. (set it to the DS prefix for your module).

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/24/15 01:29:30PM

Tags