I've found this issue while loading nodes with javascript. This made mediaelement looks for other assets at the wrong path (trying to load the swf as if it was in the drupal root folder).

The bonus with using the pluginPath setting is that it allows the mediaelement-and-player.min.js to be preprocessed. patch following

Comments

idflood’s picture

Status: Active » Needs review
StatusFileSize
new2.1 KB

This should apply to both the 7.x-1.x and 7.x-2.x branches.

idflood’s picture

StatusFileSize
new2.27 KB

Forgot to remove the 'preprocess' => FALSE

idflood’s picture

Status: Needs review » Needs work

I've tried to use the pluginPath option with mediaelement in a completly different situation but it was a little buggy (no more 404 but plugin wasn't working). Not sure what made it work in some situation or not, but I finally had to rely on the 'preprocess' => FALSE.

tea.time’s picture

+1 for passing the pluginPath to a js setting.

I just worked around the exact same issue due to rendering a node containing a video via an AJAX callback. The problem is that the js files are added with the AJAX callback, so mejs.Utility.getScriptPath() doesn't find them amongst the document's <script> elements. The pluginPath thus gets stored into mejs.MediaElementDefaults as an empty string.

Workaround I used for now, in the case of using the mediaelement.js formatter for a file type: in a preprocess function, alter the #attached array to add

...['opts']['pluginPath'] = '/' . libraries_get_path('mediaelement') . '/build/';

See mediaelement_field_formatter_view() for the structure of the #attached array.

jnettik’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes
Status: Needs work » Active

In the D8 version we're also pulling in the library via CDN, so I'm curious what the best way to handle this will be if the library isn't installed locally.