优化播放器参数

This commit is contained in:
langren1353 2021-12-12 04:46:11 +08:00 committed by luozhangbiao
parent c0d4a4ac9a
commit ce6489e01a
2 changed files with 15 additions and 8 deletions

View File

@ -2,14 +2,14 @@
"config": { "config": {
"fullInteractive": true, "fullInteractive": true,
"delay": 30, "delay": 30,
"timeFrequency": 100, "timeFrequency": 50,
"autoLoad": true, "autoLoad": true,
"loadNext": 0, "loadNext": 0,
"definition": true, "definition": true,
"subtitle": true, "subtitle": true,
"playbackRate": true, "playbackRate": true,
"smartRemove": true, "smartRemove": true,
"bufferTime": 200, "bufferTime": 300,
"rtmpBufferTime": 0, "rtmpBufferTime": 0,
"click": true, "click": true,
"doubleClick": true, "doubleClick": true,
@ -102,4 +102,4 @@
"defaultHeight": 3 "defaultHeight": 3
} }
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="file-video" ref="player" style="height: 100%; width: 100%" /> <div id="file-video" ref="player" style="height: 100%; width: 100%" />
</template> </template>
<script> <script>
export default { export default {
@ -13,31 +13,38 @@ export default {
return { return {
instance: null, instance: null,
videoConfig: { videoConfig: {
container: ".file-video", //#ID`.`class container: "#file-video", //#ID`.`class
variable: "player", // new ckplayer() variable: "player", // new ckplayer()
video: this.src, // video: encodeURIComponent(this.src), //
mobileCkControls: true, // h5 mobileCkControls: true, // h5
overspread: false, // overspread: false, //
seek: 0, // seek: 0, //
unescape: true, // flashplayer
}, },
}; };
}, },
computed: {
localKey() {
return this.src.replace(/t=d+/, ""); //
},
},
mounted() { mounted() {
this.loadProcess(); this.loadProcess();
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
this.instance = new ckplayer(this.videoConfig); // this.instance = new ckplayer(this.videoConfig); //
window.player = this.instance;
this.$nextTick(() => this.loadHandler()); this.$nextTick(() => this.loadHandler());
}, },
methods: { methods: {
loadProcess() { loadProcess() {
this.videoConfig.seek = localStorage.getItem(this.src) || 0; this.videoConfig.seek = localStorage.getItem(this.localKey) || 0;
}, },
loadHandler() { loadHandler() {
this.instance.addListener("time", this.timeHandler); // this.instance.addListener("time", this.timeHandler); //
this.instance.addListener("ended", this.VideoPlayEndedHandler); // this.instance.addListener("ended", this.VideoPlayEndedHandler); //
}, },
timeHandler(time) { timeHandler(time) {
localStorage.setItem(this.src, time); localStorage.setItem(this.localKey, time);
}, },
VideoPlayEndedHandler() {}, VideoPlayEndedHandler() {},
}, },