Using MediaelementJS in Rails

Based on the information on the site, the integration of this mediaplayer seems to be simple enough: You just need to copy over a JavaScript file to Rails’ JS folder and a stylesheet to the corresponding folder in assets. If you are not using jQuery in your app yet, you also either need to put jQuery in the JS folder – or integrate a CDN version in your application.html.erb layout (see “Using jQuery with a CDN”), for example. In this case, I used a locally installed version of jQuery, while on previous projects I usually used the CDN version – both generally work fine. What was unclear (at least for a Rails beginner like me) is where to put the image files that make up the controls of MediaelementJS.

Nevertheless, I got MediaelementJS to work “50% of the time, all the time”, with just these basic steps, right out of the box – albeit with missing images of the controls. The 50% of the time where a problem though, and having a visible play button etc. also would be “good”, so some “fixing” was necessary.

Continue reading