0

I am using Drupal url field in which I input any external url of an MP3 file hosted on Twilio Server and I then use html5 audio tag to render it as an audio file in node display. Everything looks fine until my client asked me to calculate the duration of the audio and display it as a column in my views.

Is there any way I can achieve this?

Thanks!

1 Answer 1

3

getID3 can be used to calculate the size of the file.

$fileinfo = getID3_analyze(drupal_realpath($name2));
$playtime_sec = round($fileinfo['playtime_seconds'] / 60);

//Generate playtime in minutes (for display only), @type String
$playtime_mins = $fileinfo['playtime_string'];

use the following modules to integrate with views. https://www.drupal.org/project/computed_field https://www.drupal.org/project/getid3

2
  • Its not basically a file, getID operates on a file but what I have is only url the file is hosted on remote server.
    – Shabir A.
    Oct 28, 2015 at 13:31
  • As per the code, i have posted you can specify remote path of the file to analyze the file attributes
    – Kalpan
    Oct 28, 2015 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.