怎样在html中不显示R代码,html5-video – 如何使用Coverr的代码解决html5视频无法播放的问题...

我已经从

Coverr上传了一个视频,并将HTML,CSS和JS添加到了我的主页.

但是,视频无法播放.

HTML:

Your browser does not support the video tag. I suggest you upgrade your browser.

Your browser does not support the video tag. I suggest you upgrade your browser.

CSS:

.homepage-hero-module {

border-right: none;

border-left: none;

position: relative;

}

.no-video .video-container video,.touch .video-container video {

display: none;

}

.no-video .video-container .poster,.touch .video-container .poster {

display: block !important;

}

.video-container {

position: relative;

bottom: 0%;

left: 0%;

height: 100%;

width: 100%;

overflow: hidden;

background: #000;

}

.video-container .poster img {

width: 100%;

bottom: 0;

position: absolute;

}

.video-container .filter {

z-index: 100;

position: absolute;

background: rgba(0,0.4);

width: 100%;

}

.video-container video {

position: absolute;

z-index: 0;

bottom: 0;

}

.video-container video.fillWidth {

width: 100%;

}

JS:

//jQuery is required to run this code

jQuery( document ).ready(function() {

scaleVideoContainer();

initBannerVideoSize('.video-container .poster img');

initBannerVideoSize('.video-container .filter');

initBannerVideoSize('.video-container video');

jQuery(window).on('resize',function() {

scaleVideoContainer();

scaleBannerVideoSize('.video-container .poster img');

scaleBannerVideoSize('.video-container .filter');

scaleBannerVideoSize('.video-container video');

});

});

function scaleVideoContainer() {

var height = jQuery(window).height() + 5;

var unitHeight = parseInt(height) + 'px';

jQuery('.homepage-hero-module').css('height',unitHeight);

}

function initBannerVideoSize(element){

jQuery(element).each(function(){

jQuery(this).data('height',jQuery(this).height());

jQuery(this).data('width',jQuery(this).width());

});

scaleBannerVideoSize(element);

}

function scaleBannerVideoSize(element){

var windowWidth = jQuery(window).width(),windowHeight = jQuery(window).height() + 5,videoWidth,videoHeight;

console.log(windowHeight);

jQuery(element).each(function(){

var videoAspectRatio = jQuery(this).data('height')/jQuery(this).data('width');

jQuery(this).width(windowWidth);

if(windowWidth < 1000){

videoHeight = windowHeight;

videoWidth = videoHeight / videoAspectRatio;

jQuery(this).css({'margin-top' : 0,'margin-left' : -(videoWidth - windowWidth) / 2 + 'px'});

jQuery(this).width(videoWidth).height(videoHeight);

}

jQuery('.homepage-hero-module .video-container video').addClass('fadeIn animated');

});

}

我在控制台中看不到任何错误,因此我不知道为什么视频无法在最新版本的Chrome或Firefox中播放.

帮助赞赏.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值