Is there a way to preload the duration before pressing play the first time on an audio player. I know you can use { duration: 120 } which is fine if every clip is 120 seconds long. I do not have the information available in the database to dynamically populate this variable so there must be another way to tweak the MediaElement.JS script to do it.
Any thoughts anyone?
I don’t think mediaelement.js has a way of getting the duration before all or part of the file has been downloaded. You could play the video, poll the duration property until you get a value then reset the video to the start. Though that would not be very elegant.
You could used a JavaScript library like this client side:
https://github.com/aadsm/JavaScript-ID3-Reader
If you are using PHP then you could do this server side. See PHP Function to get MP3 duration for more info.
Hope this helps.