Я использовал это решение Франссо Борзи: < /p>
var videoSrc = $("#myModal iframe").attr("src");
$('#myModal').on('show.bs.modal', function () { // on opening the modal
// set the video to autostart
$("#myModal iframe").attr("src", videoSrc+"&autoplay=1");
});
$("#myModal").on('hidden.bs.modal', function (e) { // on closing the modal
// stop the video
$("#myModal iframe").attr("src", null);
});
< /code>
fyi: этот фрагмент можно найти в этом потоке: Bootstrap Modals & YouTube: Autoplay и остановка на закрытии: < /p>
Он работает только на странице. Когда я пытаюсь открыть другое видео для каждого модала, модалы воспроизводят только последнее видео на размере. < /P>
Это мой код до сих пор: < /p>
var videoSrc = $("#modal-vimeo-01 iframe").attr("src");
$('#modal-vimeo-01').on('show.bs.modal', function () { // on opening the modal
// set the video to autostart
$("#modal-vimeo-01 iframe").attr("src", videoSrc+"&autoplay=1");
});
$("#modal-vimeo-01").on('hidden.bs.modal', function (e) { // on closing the modal
// stop the video
$("#modal-vimeo-01 iframe").attr("src", null);
});
var videoSrc = $("#modal-vimeo-02 iframe").attr("src");
$('#modal-vimeo-02').on('show.bs.modal', function () { // on opening the modal
// set the video to autostart
$("#modal-vimeo-02 iframe").attr("src", videoSrc+"&autoplay=1");
});
$("#modal-vimeo-02").on('hidden.bs.modal', function (e) { // on closing the modal
// stop the video
$("#modal-vimeo-02 iframe").attr("src", null);
});
Подробнее здесь: https://stackoverflow.com/questions/731 ... nt-vimeo-v
Мне нужно открыть 4 модала начальной загрузки (версия 4.1) и автоматически разместить различное видео Vimeo на каждом из ⇐ Jquery
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение