Okay
  Public Ticket #1855267
Youtube won't autoplay on homepage
Closed

Comments

  • Dirma started the conversation

    Dear Kalium Theme,

    The video (youtube) on the homepage of http://ahaa.nl/ won't autoplay. In 'Video and audio settings' I enabled 'auto play videos', but it doesn't autoplay everytime (sometimes it does).

    I hope you can help me with this problem!

    Kind regards, 

    Dirma

  • [deleted] replied

    Hi Dirma,

    Normally, browsers won't autoplay videos if they are not muted, read more here:

    https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

    I am giving you a code that will mute the video and this will increase the probability for video to be auto-played.

    So please add the following code in functions.php (end of file):

    function kalium_embed_video_atts_youtube_mute( $atts ) {
    if ( isset( $atts['data-vsetup']['youtube'] ) ) {
    $atts['data-vsetup']['youtube']['customVars']['mute'] = 1;
    }
    return $atts;
    }

    add_filter( 'kalium_embed_video_atts', 'kalium_embed_video_atts_youtube_mute' );