html 怎么改变视频slider的颜色,Anythingslider html 5 video autoplay

问题

please i need your help folks!

I'm using Anythingslider to slide between HTML5 video and other content, but when I add autoplay attribute in video tag, Anythingslider plays just audio.

回答1:

Are you sure the video is not hidden behind another element? Play with the z-index as the video should be visible. I've had a few issues with this in the past, such as the video flickering in and out of visibility on scroll.

I ended up playing the videos in a light box since anything slider would leave the video playing as the carousel continued to scroll. Also, if you use an infinite scroller there were also issues with it playing the video in two places.

Providing you are using something like JW Player you will be able to set up some actions to pause the video on slide or similar but basic youtube embeds will be an issue.

回答2:

Don't add the autoplay attribute to HTML5 video. What is probably happening is that the cloned copy of the video (first and last slides only) is playing the video, but all you hear is the audio since the panel is not in view. The reason you don't want to autoplay is because it will still autoplay even if AnythingSlider starts with another slide visible, and it won't stop until you cycle through the panels.

If you want the video to autoplay when the panel is visible, you'll have to add some script into the completed callback (video extension is not required with the code below; demo):

var playvid = function(slider) {

var vid = slider.$currentPage.find('video');

if (vid.length) {

// autoplay

vid[0].play();

}

};

$('#slider').anythingSlider({

// Autoplay video in initial panel, if one exists

onInitialized: function(e, slider) {

playvid(slider);

},

// pause video when out of view

onSlideInit: function(e, slider) {

var vid = slider.$lastPage.find('video');

if (vid.length && typeof(vid[0].pause) !== 'undefined') {

vid[0].pause();

}

},

// play video

onSlideComplete: function(slider) {

playvid(slider);

},

// pause slideshow if video is playing

isVideoPlaying: function(slider) {

var vid = slider.$currentPage.find('video');

return (vid.length && typeof(vid[0].pause) !== 'undefined' && !vid[0].paused && !vid[0].ended);

}

});​

来源:https://stackoverflow.com/questions/12285052/anythingslider-html-5-video-autoplay

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值