Usage
nebula.pauseAllVideos(force)
Parameters
force
(Optional) (Boolean) Force all videos to pause no matter what.
Default: None
Parameter Notes
An iframe with the class ignore-visibility
will allow that video to continue playing regardless of page visibility.
If force
is true, all videos will pause regardless.
Additional Notes
Important note: This function can only pause videos that are “known” to Nebula- only Youtube and Vimeo videos that are connected into the Nebula players object.
Source File
Located in /assets/js/modules/video.js on line 799.
No Hooks
This function does not have any filters or actions available. Request one?nebula.pauseAllVideos = function(force = false){ if ( typeof nebula.videos === 'undefined' ){ return false; //If videos don't exist, then no need to pause } jQuery.each(nebula.videos, function(){ if ( this.platform === 'html5' ){ if ( (force || !jQuery(this.element).hasClass('ignore-visibility')) ){ jQuery(this.element)[0].pause(); //Pause HTML5 Videos } } if ( this.platform === 'youtube' ){ if ( (force || !jQuery(this.element).hasClass('ignore-visibility')) ){ this.player.pauseVideo(); //Pause Youtube Videos } } if ( this.platform === 'vimeo' ){ if ( (force || !jQuery(this.element).hasClass('ignore-visibility')) ){ this.player.pause(); //Pause Vimeo Videos } } }); };
Override
To override or disable this JavaScript function, simply redeclare it with the exact same function name. Remember: Some functionality is conditionally loaded via dynamic imports, so if your function is not overriding properly, try listening for a DOM event (described below).
For non-module import functions:
nebula.pauseAllVideos = function(force){ //Write your own code here, leave it blank, or return false. }
For dynamically imported module function overrides:
jQuery(window).on('load', function(){ nebula.pauseAllVideos = function(force){ //Write your own code here, leave it blank, or return false. } });
Custom Nebula DOM events do also exist, so you could also try the following if the Window Load listener does not work:
jQuery(document).on('nebula_module_loaded', function(module){ //Note that the module variable is also available to know which module specifically was imported if ( typeof nebula.pauseAllVideos === 'function' ){ nebula.pauseAllVideos = function(force){ //Write your own code here, leave it blank, or return false. } } });