سؤال

When using Bootstrap 3 modal windows normally the content is there, in the same window, so, whenever you close a modal, you just hide it within the same page. If it's a <video>, it'll keep playing until you refresh the page, or re-open the modal just to pause it (since it can't be stopped).
How do you pause a video inside a Bootstrap modal?

هل كانت مفيدة؟

المحلول 2

I found this to be an option to work for all my modals with (using Mediaelement.js) inside them.

$('.modal').on('hidden.bs.modal', function () {
    $('video').each(function() {
      this.player.pause();
    });
})

نصائح أخرى

I searched all over the internet for an answer for this question. none worked for me except this code. Guaranteed. It work perfectly.

$('body').on('hidden.bs.modal', '.modal', function () {
$('video').trigger('pause');
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top