Skip to content

Commit

Permalink
优化播放器参数
Browse files Browse the repository at this point in the history
  • Loading branch information
langren1353 authored and luozhangbiao committed Dec 21, 2021
1 parent c0d4a4a commit ce6489e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions frontend/public/ckplayer/ckplayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"config": {
"fullInteractive": true,
"delay": 30,
"timeFrequency": 100,
"timeFrequency": 50,
"autoLoad": true,
"loadNext": 0,
"definition": true,
"subtitle": true,
"playbackRate": true,
"smartRemove": true,
"bufferTime": 200,
"bufferTime": 300,
"rtmpBufferTime": 0,
"click": true,
"doubleClick": true,
Expand Down Expand Up @@ -102,4 +102,4 @@
"defaultHeight": 3
}
}
}
}
17 changes: 12 additions & 5 deletions frontend/src/views/files/Video.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="file-video" ref="player" style="height: 100%; width: 100%" />
<div id="file-video" ref="player" style="height: 100%; width: 100%" />
</template>
<script>
export default {
Expand All @@ -13,31 +13,38 @@ export default {
return {
instance: null,
videoConfig: {
container: ".file-video", //“#”代表容器的ID,“`.`”或“”代表容器的class
container: "#file-video", //“#”代表容器的ID,“`.`”或“”代表容器的class
variable: "player", // 播放函数名称,该属性必需设置,值等于下面的new ckplayer()的对象
video: this.src, // 视频地址
video: encodeURIComponent(this.src), // 视频地址
mobileCkControls: true, // 移动端h5显示控制栏
overspread: false, //是否让视频铺满播放器
seek: 0, // 默认需要跳转的秒数
unescape: true, // 默认flashplayer里需要解码
},
};
},
computed: {
localKey() {
return this.src.replace(/t=d+/, ""); // 避免时间戳的干扰
},
},
mounted() {
this.loadProcess();
// eslint-disable-next-line no-undef
this.instance = new ckplayer(this.videoConfig); //初始化播放器
window.player = this.instance;
this.$nextTick(() => this.loadHandler());
},
methods: {
loadProcess() {
this.videoConfig.seek = localStorage.getItem(this.src) || 0;
this.videoConfig.seek = localStorage.getItem(this.localKey) || 0;
},
loadHandler() {
this.instance.addListener("time", this.timeHandler); //监听播放时间
this.instance.addListener("ended", this.VideoPlayEndedHandler); //监听播放结束
},
timeHandler(time) {
localStorage.setItem(this.src, time);
localStorage.setItem(this.localKey, time);
},
VideoPlayEndedHandler() {},
},
Expand Down

0 comments on commit ce6489e

Please sign in to comment.