height: 58px;
background: rgba(15, 16, 17, 0.3);
border-radius: 50%;
position: relative;
.ball-clip-rotate {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
> div {
width: 15px;
height: 15px;
border-radius: 100%;
margin: 2px;
animation-fill-mode: both;
border: 2px solid #fff;
border-bottom-color: transparent;
height: 26px;
width: 26px;
background: transparent;
display: inline-block;
animation: rotate 0.75s 0s linear infinite;
}
}
}
播放时间设置
基本就是video对象的currentTime和duration这两个属性; 这里注意下视频如果没有设置预加载属性preload的话,在video元素初始化的时候是获取不到duration的…那你只能在播放的时候去拿了.
// 获取播放时间
getPlayTime() {
const percent = this.$video.currentTime / this.$video.duration;
this.video.progress.current = Math.round(
this.video.progress.width * percent
);
// 赋值时长
this.video.totalTime = timeParse(this.$video.duration);
this.video.displayTime = timeParse(this.$video.currentTime);
},
// 获取缓存时间
getLoadTime() {
// console.log('缓存了...',this.$video.buffered.end(0));
this.video.loaded =
(this.$video.buffered.end(0) / this.$video.duration) * 100;
},手动滑动进度条控制
这里直接用touch事件即可; 注意touchend中使用e.changedTouches;因为当手指离开屏幕,touches和targetTouches中对应的元素会同时移除,而changedTouches仍然会存在元素。
touches: 当前屏幕上所有触摸点的列表;
targetTouches: 当前对象上所有触摸点的列表;
changedTouches: 涉及当前(引发)事件的触摸点的列表
// 手动调节播放进度
moveStart(e) {},
moveIng(e) {
// console.log("触摸中...");
let currentX = e.targetTouches[0].pageX;
let offsetX = currentX - this.progressBar.pos.left;
// 边界检测
if (offsetX <= 0) {
offsetX = 0
}
if (offsetX >= this.video.progress.width) {
offsetX = this.video.progress.width
}
this.video.progress.current = offsetX; let percent = this.video.progress.current / this.video.progress.width;
this.$video.duration && this.setPlayTime(percent, this.$video.duration)
},
moveEnd(e) {
// console.log("触摸结束...");
let currentX = e.changedTouches[0].pageX;
let offsetX = currentX - this.progressBar.pos.left;
this.video.progress.current = offsetX;
// 这里的offsetX都是正数
let percent = offsetX / this.video.progress.width;










