猫头鹰旋转木马中的HTML5视频,带有圆形自动播放视频和carosel

时间:2016-10-04 14:07:37

标签: jquery html5 html5-video owl-carousel owl-carousel-2

以下代码适用于圆形视频和轮播自动播放,但问题是在更改浏览器窗口标签时,经过一段时间后,此标签视频卡住了,我的循环停止了。

import csv
my_file_name = "NVG.txt"
cleaned_file = "cleanNVG.csv"

with open(my_file_name, 'r') as infile, open(cleaned_file, 'w') as outfile:
    data = infile.read()

    data = data.replace("|","")
    outfile.write(data)
var owl = $('.owl-carousel');
$('.owl-carousel').owlCarousel({
  items: 1,
  loop: true,
  dots: false,
  video: true,
  autoplay: true,
  onInitialized: function() {
    if ($(".owl-item.active video", this.$element).length) {
      $(".owl-item.active video", this.$element)[0].play();
      owl.trigger('stop.owl.autoplay')
      $(".owl-item.active video", this.$element).on('ended', function() {
        owl.trigger('play.owl.autoplay')
      });
    }
  },
  onTranslated: function() {
    if ($(".owl-item.active video", this.$element).length) {
      $(".owl-item.active video", this.$element)[0].play();
      owl.trigger('stop.owl.autoplay')
      $(".owl-item.active video", this.$element).on('ended', function() {
        owl.trigger('play.owl.autoplay')
      });
    }
  }
});

1 个答案:

答案 0 :(得分:0)

首先,我遇到了同样的问题,这对我帮助很大,所以谢谢你。

为了解决您的问题,我刚刚在两个“已结束”功能中添加了$(".owl-item.active video", this.$element)[0].play();而不是owl.trigger('play.owl.autoplay'),即使在多个视频之间来回切换,离开然后再次切换,它也能完美地为我工作。