bxslider停止视频元素自动播放 [英] bxslider stopping video element autoplay
问题描述
我正在使用Bx滑块作为标准轮播。其中一张幻灯片有一个带自动播放的元素并循环播放以用作背景。
I'm using Bx slider for a standard carousel. One of the slides has a element with autoplay and loop on to use as a background.
问题是由于某种原因bx滑块阻止视频播放。是否有一种已知的方法来覆盖此行为。
The issue is for some reason bx slider stops the video from playing. Is there a known way to override this behaviour.
当页面加载时视频播放正常,直到bxslider的js触发并停止。
The video plays fine when the page is loading until the js for bxslider fires and it stops.
我正在使用bxslider的开箱即用配置,而li里面是:
I'm using the out of the box config for bxslider, and inside the li is this:
<video preload="" loop="" autoplay="" class="video-bg">
<source src="<?php echo get_template_directory_uri(); ?>/library/images/tbf/flag.mp4" type="video/mp4">
<source src="<?php echo get_template_directory_uri(); ?>/library/images/tbf/flag.ogv" type="video/ogg">
</video>
提前致谢!
推荐答案
通过使用回调,我设置选项来播放所有视频。不是一个优雅的解决方案,但现在还不错:
By using callbacks, I set in the options to play all videos. Not an elegant solutions but good enough for now:
jQuery(document).ready(function(){
jQuery('.top-carousel').bxSlider({
onSliderLoad: function(){
jQuery('video').trigger('play');
},
onSlideAfter: function(){
// jQuery('video').trigger('play');
}
});
});
这篇关于bxslider停止视频元素自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!