Skip to Content
Menu

pauseAllVideos()

Pause all videos on the page.

JavaScript February 7, 2021

Usage

JavaScript
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.

Request or provide clarification »

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.

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /assets/js/modules/video.js on line 734.

    No Hooks

    This function does not have any filters or actions available. Request one?
    JavaScript
    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.

    JavaScript
    nebula.pauseAllVideos = function(force){
        //Write your own code here, leave it blank, or return false.
    }