Play and stop Vimeo video placed in Bootstrap modal

前端 未结 5 916
不知归路
不知归路 2021-01-01 03:21

I have a Vimeo iframe video in Bootstrap video. I need to have it start playing when I trigger modal and stop playing when a modal is closed. Currently I can have in start p

5条回答
  •  孤独总比滥情好
    2021-01-01 03:38

    I accomplished this by calling both the Bootstrap Modal API and Vimeo API, code below. You will need to include Vimeo's Froogaloop script as well, also below.

    
    
    $('.modal').on('hidden.bs.modal', function () {
    player.api('pause');
    })
    
    $('.modal').on('shown.bs.modal', function () {
    player.api('play');
    })
    

提交回复
热议问题