Play and stop Vimeo video placed in Bootstrap modal

前端 未结 5 921
不知归路
不知归路 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:44

    Refer to Vimeo's embedding documentation.

    There is an attribute that you can set called autoplay. They note that it might not work on some devices, but setting this attribute to 1 (or maybe true) should help.

    The code might look something like this:

    jQuery('#myModal .modal-body iframe').attr({
        src: 'the-source-code',
        autoplay: 1
    });
    

提交回复
热议问题