优化播放器参数
This commit is contained in:
parent
c0d4a4ac9a
commit
ce6489e01a
@ -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,
|
||||||
|
|||||||
@ -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() {},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user