Although there's no error path. The css and js file (video.js / video-js.min.css / video-js.css) doesn't load in the drupal content page.

and no script for alternate flash player;

Drupal 7.2.8 / video.js module 7.x2.3 / video-js-4.6.3 library

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sebcolor’s picture

Version: 7.x-2.3 » 7.x-3.x-dev

I do the upgrade to version 7.x-3.0-alpha2+9-dev… And it's fixed up ! Sorry ;-)

huteb’s picture

Hi,

I have the same problem. More precisely, everything loads fine after emptying the cache, but in subsequent page reloads the js/css are not added.

It actually seems that the "videojs_preprocess_videojs" function is not called after the first page load. I deactivated all cache in the performance settings and tester as admin and anonymous, always the same issue.

I tried v2.x, 3.x and the latest dev and reproduce at each time.

Jody Lynn’s picture

The problem is that the css/js is added in videojs_field_formatter_view which is not a safe place to add these. The results of this function will get cached by page cache or, in case you are embedding the video within formatted text, in filter cache.

I suppose this is why so many drupal modules simply add their css/js to every page in hook_init.

I worked around it by adding videojs_add(); within a hook_node_view (or use hook_init) in a custom module.

mglaman’s picture

Status: Active » Closed (works as designed)

The current implementation is right and uses #attached. Also CSS/JS shouldn't be added on init because it'll bypass caching too many times.

This issue is definitely occurring when using Media + WYSIWYG. The body field's output is saved to cache_field. The entire HTML output for the Video.js inline video is saved in the cache. When the node (or other entity supporting field cache) is loaded, this output is pulled in. The function drupal_render isn't run which means the theming layer is skipped (because we have a cached output.)

It seems that if you'd like to support Video.js (or any other library required within Media + WYSIWYG) you'll need to manually add the library on hook_page_build or hook_entity_view (if you want to keep it specific.)

PascalAnimateur’s picture

The mediaelement module has an option to enable it site wide (always load the js and css files), which would fix this issue but takes up extra bandwidth on pages without videos in them.

Here's a patch that implements that for videojs while we wait for media_wysiwyg to detect/inject attached js and css files to the fields when building the cache.