Closed (duplicate)
Project:
JW Player
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Oct 2011 at 16:07 UTC
Updated:
2 May 2016 at 19:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jarrodirwin commentedI have created a rough patch that inserts the JW Player code into the template if a inline_js variable is set.
@todo
-Create UI to set/unset the inline variable.
-Only add jwplayer.js if the page contains a video
Comment #2
jarrodirwin commentedChanging to needs review
Comment #3
rickvug commented@Jarrod Thanks for the patch! I think the approach is right but there could be a few changes:
Comment #4
jarrodirwin commentedAttached new patch.
-Now uses hook_init
-Variables are added to the js by looping through $variables['config']
-Removed drupal_html_id()
-Tidied up code to conform to drupal standards
As for using drupal_add_js() to insert the js, this doesn't look possible as the inline scope is only header or footer, both of which do not get cached and the same issue arises. You are meant to be able to add it to specific regions but looks like that was never implemented. See http://drupal.org/node/812388
It is a shame as that would be the cleaner way to add the inline js.
Comment #5
rickvug commented@Jarrod Thanks for the updated patch. Sorry about my delay in responding. Attached is a slightly modified version to fix a few (minor) white space and capitalisation errors. An "interdiff" is attached as well to make it easy to see the changes since last time. To finish this off I'd like to see a few things:
Aside from these clean up issues things are looking good. Depending on time I may end up taking on some of this work.
Comment #6
rickvug commentedComment #7
girishmuraly commentedHere's the patch applied to the latest commit
json_encode()Comment #8
girishmuraly commentedI had forgotten to attach theme/jw_player.tpl.php.
Comment #9
girishmuraly commentedJust noticed a bug with patch #8:
If a preset plugin is being used and then later turned off at a later date, the preset would still have the settings of the disabled plugin and would continue to output their setttings to the player in the javascript.
Comment #10
girishmuraly commentedAttached patch with better checking of loading preset plugin settings based on only the available (module enabled) plugins.
Comment #11
rickvug commentedCommitted! Thanks Girish and Jarrod. I made a few small changes to the documentation but otherwise this is your guy's work.
The plugin issue that Girish raised in comment #9 has been split off into its own bug report: #1348518: Presets can reference plugins that are no longer available. I agree with the solution but I don't think it is appropriate to send along all variables.
Comment #13
jethro commentedIt appears this issue has resurfaced in the 7.x-2.x branch of the module.
I it better to open a new issue or revive this ticket?
When a player is inserted through a wysiwyg player, like with the media module, the page is cached and subsequent page loads are missing
drupal_add_js(libraries_get_path('jwplayer') . '/jwplayer.js');
drupal_add_js(drupal_get_path('module', 'jw_player') . '/jw_player_seek.js');
The player is unable to load.
I don't see a better way than to add these in hook_init. Would it be preferable if this was a setting as not all sites may encounter this issue?
Comment #14
pbuyle commentedWhich cache is actually causing the issue?
Instead of using
drupal_add_js(), could#attachedbe used somewhere in a cached renderable array?Comment #15
pbuyle commentedPage cache does include the JS added with
drupal_add_js(). So the page being cached is not the issue. Could there be some other cache involved? How is the embed code inserted in the WYSIWYG created? Is the embedding done through a filter?Comment #16
pbuyle commentedComment #18
sgdev commentedMarking this as duplicate since the refactor theming patch removes all inline JavaScript and renders players using
#attachedandDrupal.behaviors.Please review: https://www.drupal.org/node/2713725
Comment #19
sgdev commentedSorry, forgot to change the status.