Problem/Motivation
The module currently adds inline_js through the template, that it has to encode by hand. It also requires that the jw player is already loaded in the header.
Proposed resolution
This is going back to the optional feature in 7.x, this time, it's always on as #attached is working reliably in 8.x
This cleans up template preprocessing as we no longer have to do json encoding ourselv or printing inline JS. It also means that all the JS can be moved into the footer.
This also removes custom plugins. I think most of that can be handled with standard third party settings in 8.x, if not, we can always re-add if something is missing.
This is a rather big API change, as using #theme jw_player will no longer work. So custom integrations will break. Still seem important enough to do.
Remaining tasks
Improve and fix tests.
User interface changes
API changes
#theme jw_player is replaced with #type jw_player.
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | interdiff-2712615-2-4.txt | 4.25 KB | johnchque |
| #4 | introduce_jw_player-2712615-4.patch | 16.18 KB | johnchque |
| #2 | jw-player-type-js-2712615-2.patch | 12.83 KB | berdir |
Comments
Comment #2
berdirComment #4
johnchqueChanges made on the tests and some small comment fixing. Should be OK, let's see if testbot agrees.
Comment #5
johnchqueComment #7
berdirTested this with our project, works well.
Comment #8
sgdev commentedI don't think it's a good idea to use this line:
Adding a random string on the end means
#html_idwill never be constant. This is an issue if attempting to use hooks. Also given that all of JW Player 7 items are controlled through CSS, the div id needs to be a static value for themers.Please see how we handled this in the newest Refactor theming patch: https://www.drupal.org/node/2713725#comment-11144633
Similar to what is currently done in 7.x-2.x, we are creating a string based on player type, item id, and preset name. This allows us to do the following in the API, where
$idis a machine name version of the value created from the code above:Comment #9
berdirThe HTML ID shouldn't be used for theming anyway, happy to add more classes if needed. Alter hooks for fine, I have one myself where I'm adding a preview image, a bit complicated but you can easily access the ID there and adjust #attached with that key.
I did that altering in 8.x using an element_info_alter hook that adds a second pre_render callback, no special hook necessary. Although I guess it would be a bit easier if one would exist.
We had this before in exactly the same way, it's just a fallback if none is given.
It's very important for that ID to be unique, we've had cases where the same file is displayed multiple times
Comment #10
sgdev commentedIt is not possible to add classes, unless it is done in a wrapper. JW Player strips any classes added to the player and replaces it with their own.
I understand about the ID needing to be unique, that is important. However having it be random is not a good situation either. I've never heard of situations where the id of a media player div tag continually changes every time a page is loaded.
It is not possible to string together enough components to create an ID that is unique, but doesn't change every time the page renders?
Comment #11
sgdev commentedAlso to be clear, HTML ID isn't being used for theming. In the refactor theming patch, we're using a variation of HTML ID to create a unique machine name. We need to create something unique for theming -- I'm not sure what else might be used, what would you recommend?