增加本地播放进度缓存

This commit is contained in:
langren1353 2021-12-12 01:01:40 +08:00 committed by luozhangbiao
parent 45b119c1f9
commit c0d4a4ac9a

View File

@ -1,8 +1,7 @@
<template>
<div class="file-video" ref="player" style="height: 100%; width: 100%"/>
<div class="file-video" ref="player" style="height: 100%; width: 100%" />
</template>
<script>
export default {
props: {
src: {
@ -13,18 +12,34 @@ export default {
data() {
return {
instance: null,
videoConfig: {
container: ".file-video", //#ID`.`class
variable: "player", // new ckplayer()
video: this.src, //
mobileCkControls: true, // h5
overspread: false, //
seek: 0, //
},
};
},
mounted() {
var videoObject = {
container: ".file-video", //#ID`.`class
variable: "player", // new ckplayer()
video: this.src, //
mobileCkControls: true, // h5
overspread: false, //
};
this.loadProcess();
// eslint-disable-next-line no-undef
this.instance = new ckplayer(videoObject); //
this.instance = new ckplayer(this.videoConfig); //
this.$nextTick(() => this.loadHandler());
},
methods: {
loadProcess() {
this.videoConfig.seek = localStorage.getItem(this.src) || 0;
},
loadHandler() {
this.instance.addListener("time", this.timeHandler); //
this.instance.addListener("ended", this.VideoPlayEndedHandler); //
},
timeHandler(time) {
localStorage.setItem(this.src, time);
},
VideoPlayEndedHandler() {},
},
};
</script>