Muting an embedded vimeo video

前端 未结 12 2243
攒了一身酷
攒了一身酷 2020-12-14 07:42

On a website I am building I have a vimeo video embedded. The client needs to keep the sound on the video obviously for people that find it on vimeo. However for her website

12条回答
  •  抹茶落季
    2020-12-14 08:00

    I've found a way to do it. You start the video muted so it autoplays, then on the first timeupdate you set the volume to 1.

    var options = {
        id: 'video_id_here',
        width: 640,
        loop: false,
        muted: true,
        autoplay: true
    };
    
    var player = new Vimeo.Player('vimeo', options);
    
    player.setVolume(0);
    
    player.on('timeupdate', set_autoplay_volume );
    
    function set_autoplay_volume(){
        player.setVolume(1);
        player.off('timeupdate', set_autoplay_volume );
    }
    

提交回复
热议问题