mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-11 20:06:48 +08:00
视频器拖动调整
This commit is contained in:
@@ -22,9 +22,22 @@
|
||||
<image :src="require(playing? './images/pause.png':'./images/play.png')" @click.stop='videoOpreation'/>
|
||||
</view>
|
||||
<view class="currtime">{{currtime}}</view>
|
||||
<view class='slider-container'>
|
||||
<slider :disabled="!drag" @change.stop="sliderChange" @changing="sliderChanging" step="1" :value="sliderValue" backgroundColor="#9f9587" activeColor="#d6d2cc" block-color="#FFFFFF" block-size="12"/>
|
||||
<!-- <cover-view v-if="drag" class='slider-container'>
|
||||
<slider @change.stop="sliderChange" @changing="sliderChanging" step="1" :value="sliderValue" backgroundColor="#9f9587" activeColor="#d6d2cc" block-color="#FFFFFF" block-size="12"/>
|
||||
<slider v-if="!drag" disabled="true" step="1" :value="sliderValue" backgroundColor="#9f9587" activeColor="#d6d2cc" block-color="#FFFFFF" block-size="12"/>
|
||||
</cover-view> v-if="!drag" -->
|
||||
<view class='slider-container new-bar'>
|
||||
<progressBar
|
||||
:currentProgress="sliderValue"
|
||||
:blobId="blobId"
|
||||
v-on:updateProgress="updateProgressByClickBar"
|
||||
v-on:getMouseDownStatus="getMouseDownStatusOfProgressBar"
|
||||
:isDrag="drag"
|
||||
width="100%"
|
||||
></progressBar>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="druationTime">{{druationTime}}</view>
|
||||
<view class="druationTime">
|
||||
<view id="myVideoSpeed" class="player-speed btn-speed">
|
||||
@@ -51,14 +64,21 @@
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import progressBar from "@/components/video-player/progress-bar.vue";
|
||||
import {mapGetters} from 'vuex'
|
||||
import studyUtil from '@/utils/study.js';
|
||||
export default {
|
||||
components: { progressBar },
|
||||
props: {
|
||||
url:{
|
||||
type: String,
|
||||
require: true
|
||||
},
|
||||
// 视频链接对应的content Id
|
||||
blobId: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
watermark:{
|
||||
type: Boolean,
|
||||
default: true
|
||||
@@ -89,12 +109,15 @@
|
||||
updateState: true, //防止视频播放过程中导致的拖拽失效
|
||||
playing:false,//是否在播放中
|
||||
curVideo:{
|
||||
duration:0
|
||||
duration:0,
|
||||
currentTime: 0
|
||||
},
|
||||
touchNum:0,
|
||||
speedListShow:false,
|
||||
speedList:["2.0", "1.5", "1.25", "1.0", "0.75", "0.5"],
|
||||
videoSpeed: 1.0, // 当前倍速:
|
||||
isMousedownProgress: false, // 鼠标是否按下了进度条(并未松开)
|
||||
historyTime: 0 // 当前视频
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -114,6 +137,36 @@
|
||||
this.videoContext=uni.createVideoContext("xvideoPlayer", this);
|
||||
},
|
||||
methods: {
|
||||
/* 点击进度条更新视频播放进度
|
||||
*/
|
||||
updateProgressByClickBar(value) {
|
||||
console.log('value------:',value)
|
||||
let duration = this.curVideo.duration;
|
||||
|
||||
let new_current_time = Math.round(value * duration);
|
||||
// this.barrageTimelineStart = new_current_time;
|
||||
this.curVideo.currentTime = new_current_time;
|
||||
this.sliderValue = value * 100;
|
||||
this.videoContext.seek(new_current_time);
|
||||
|
||||
|
||||
// var duration=this.curVideo.duration;
|
||||
// var second=e.detail.value / 100 * duration;
|
||||
// if (duration) { //完成拖动后,计算对应时间并跳转到指定位置
|
||||
// this.videoContext.seek(second);
|
||||
// this.sliderValue= e.detail.value,
|
||||
// this.updateState= true //完成拖动后允许更新滚动条
|
||||
// this.druationTime = this.formatSeconds(duration);
|
||||
// this.currtime = this.formatSeconds(second);
|
||||
// }
|
||||
|
||||
|
||||
},
|
||||
/* 获取鼠标是否按下了进度条
|
||||
*/
|
||||
getMouseDownStatusOfProgressBar(value) {
|
||||
this.isMousedownProgress = value;
|
||||
},
|
||||
// 全屏+退出全屏
|
||||
fullScreen(){
|
||||
if(this.fullScreenFlag){
|
||||
@@ -161,18 +214,50 @@
|
||||
},
|
||||
// 播放进度变化时触发,event.detail = {currentTime, duration} 。触发频率 250ms 一次
|
||||
videoUpdate(e) {
|
||||
|
||||
this.historyTime = e.detail.currentTime
|
||||
|
||||
let duration=this.curVideo.duration;
|
||||
let sliderValue = e.detail.currentTime / duration * 100;
|
||||
let second=sliderValue / 100 * duration;
|
||||
|
||||
// console.log('onTimeUpdate11111::',this.drag,second)
|
||||
// if(!this.drag){
|
||||
// this.videoContext.seek(second);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
if (this.updateState) { //判断拖拽完成后才触发更新,避免拖拽失效
|
||||
this.sliderValue=sliderValue;
|
||||
this.$emit('progress',this.sliderValue);
|
||||
}else{
|
||||
|
||||
}
|
||||
// alert(this.sliderValue)
|
||||
this.druationTime = this.formatSeconds(duration);
|
||||
//console.log(this.druationTime,'this.druationTime');
|
||||
this.currtime = this.formatSeconds(second);
|
||||
|
||||
// var time = localStorage.getItem('videoProgressData')
|
||||
// //alert(1)
|
||||
// if(time && !this.drag || !this.drag && !time ){
|
||||
// var arr = time&&JSON.parse(time) || {}
|
||||
// if(arr[this.url] < this.sliderValue/100 || !arr[this.url]){
|
||||
// arr[this.url] = this.sliderValue/100
|
||||
// localStorage.setItem('videoProgressData',JSON.stringify(arr))
|
||||
// }
|
||||
// }
|
||||
// 视频播放时本地记录视频实时播放时长,视频设置了禁止拖动时执行
|
||||
if(!this.drag){
|
||||
var time = localStorage.getItem('videoProgressData')
|
||||
var arr = time&&JSON.parse(time) || {}
|
||||
if(arr[this.blobId] < this.sliderValue/100 || !arr[this.blobId]){
|
||||
arr[this.blobId] = parseFloat((this.sliderValue/100).toFixed(8))
|
||||
if(arr[this.blobId]) localStorage.setItem('videoProgressData',JSON.stringify(arr))
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
//拖动过程中触发的事件
|
||||
sliderChanging(e) {
|
||||
@@ -249,7 +334,7 @@
|
||||
this.contrlShow=!this.contrlShow;
|
||||
}else{
|
||||
if(!this.contrlShow){
|
||||
this.contrlShow=show;
|
||||
this.contrlShow=true;
|
||||
}
|
||||
}
|
||||
// this.onPlayerPause()
|
||||
@@ -348,6 +433,9 @@
|
||||
flex:6;
|
||||
max-width:50%;
|
||||
}
|
||||
.slider-container.new-bar{
|
||||
margin: 7px 10px 10px 10px;
|
||||
}
|
||||
.controller-play{
|
||||
width: 8%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user