WordPress custom video header enable audio

Posted: edited May 18 at 23:32 - Source : stackoverflow

WordPress custom video header sound is muted by default in core and there's no easy way around to get it playing audio. i really need it to play audio as well :( but could not figure out how i can do it to play audio.

things i've done so far.

after looking into core files i found wp-custom-header.js and audio is disabled via this file on line 279 video.muted = 'muted';

so i am not sure if we can modify this js file via any hook? looking to dequeue this file to replace it with my own version

wp_dequeue_script( 'wp-custom-header' );

or

wp_deregister_script( 'wp-custom-header' );

none of them are working for me. it would be great if anybody guide me on how to enable audio with banner videos or can i dequeue this core js file?

Update source from wp-includes/themes.php where this wp-custom-header.js is enqueued. and this function is responsible for displaying custom headers.

function the_custom_header_markup() {
    $custom_header = get_custom_header_markup();
    if ( empty( $custom_header ) ) {
        return;
    }

    echo $custom_header;

    if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
        wp_enqueue_script( 'wp-custom-header' );
        wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', get_header_video_settings() );
    }
}

looking at twentyseventeen i have found that they are calling the_custom_header_markup in theme header without any action hook.