This commit is contained in:
@fawn-nine
2024-07-23 16:24:52 +08:00
parent 85d2d7f41b
commit dfaa65c7a2

View File

@@ -167,18 +167,8 @@
// 退出全屏 // 退出全屏
const ctx = this.$refs.myVideo; const ctx = this.$refs.myVideo;
ctx.exitFullScreen(); ctx.exitFullScreen();
}, },
// 播放进度改变 //
// videoTimeUpdateEvent(e) {
// this.playTime = parseInt(e.detail.currentTime);
// this.currentTime = parseInt(e.detail.currentTime);
// this.allTime = parseInt(e.detail.duration);
// this.recordTime({
// time: this.playTime,
// });
// },
async init(data, isChange) { async init(data, isChange) {
this.show = false; this.show = false;
this.platform = this.$platform; this.platform = this.$platform;
@@ -248,6 +238,7 @@
}); });
}); });
}, },
// 配置播放项
async getData(data, isChange) { async getData(data, isChange) {
var that = this; var that = this;
if (!this.isSetFirstTime) { if (!this.isSetFirstTime) {
@@ -289,10 +280,7 @@
} }
this.isSetFirstTime = true; this.isSetFirstTime = true;
}, },
async playVideo(e) { // 存储本地播放时间
this.videoContext = uni.createVideoContext("videoId", this);
this.videoContext.seek(this.firstTime);
},
recordTime(data) { recordTime(data) {
// console.log('recordTime',data.time); // console.log('recordTime',data.time);
this.currentTime = data.time; this.currentTime = data.time;
@@ -301,9 +289,7 @@
if (uni.getStorageSync("videoOssList")) { if (uni.getStorageSync("videoOssList")) {
list = JSON.parse(uni.getStorageSync("videoOssList")); list = JSON.parse(uni.getStorageSync("videoOssList"));
} }
var index = list.findIndex((e) => e.id == this.videoData.id);
var index = list.findIndex((e) => e.id == this.videoData.id);
// console.log('recordTime------',index,list );
if (list.length > 0 && index >= 0) { if (list.length > 0 && index >= 0) {
list[index] = { list[index] = {
@@ -316,10 +302,9 @@
time: data.time, time: data.time,
}); });
} }
uni.setStorageSync("videoOssList", JSON.stringify(list)); uni.setStorageSync("videoOssList", JSON.stringify(list));
}, },
// 获取数据 // 获取播放凭证
async getLive(isChange) { async getLive(isChange) {
var that = this; var that = this;
this.isfresh = false; this.isfresh = false;
@@ -385,13 +370,10 @@
that.$forceUpdate(); that.$forceUpdate();
}); });
}, },
async handleEnd() {
// console.log('进来了吗handleEnd') async handleEnd() {
console.log("找到了吗????",this.videoData.id);
var list = JSON.parse(uni.getStorageSync("videoOssList")); var list = JSON.parse(uni.getStorageSync("videoOssList"));
var data = list.find((e) => e.id == this.videoData.id); var data = list.find((e) => e.id == this.videoData.id);
console.log("找到了吗????");
// data.time ? this.currentTime = data.time : this.currentTime = 0;
this.currentTime = data.time; this.currentTime = data.time;
console.log( console.log(
"this.currentTime at line 这是结束的时候掉的存储视频:", "this.currentTime at line 这是结束的时候掉的存储视频:",
@@ -401,12 +383,14 @@
clearInterval(this.$store.state.videoTimer); clearInterval(this.$store.state.videoTimer);
this.timer = null; this.timer = null;
}, },
// 存储时长到线上
setVideoTime(time) { setVideoTime(time) {
var data = {}; var data = {};
console.log("是否走了存储视屏," + this.videoData.id, this.currentTime); console.log("是否走了存储视屏," + this.videoData.id, this.currentTime);
var data = { var data = {
videoId: this.videoData.id, videoId: this.videoData.id,
position: this.currentTime, //秒数 position: this.currentTime, //秒数
loadAnimate: 'none',
}; };
$http $http
@@ -433,7 +417,7 @@
delta: 1, delta: 1,
}); });
}, },
// 设置初始播放时间 并开启定时器
async setVideoFirtsetTime(time) { async setVideoFirtsetTime(time) {
this.currentTime = this.firstTime; this.currentTime = this.firstTime;
console.log("这里准备开始设置播放时间:", this.currentTime); console.log("这里准备开始设置播放时间:", this.currentTime);
@@ -738,23 +722,11 @@
source: this.videoData.videoUrl source: this.videoData.videoUrl
} }
console.log('这是没有加密的视频'); console.log('这是没有加密的视频');
} }
var player = new Aliplayer(playerOptions, function(player) {}); var player = new Aliplayer(playerOptions, function(player) {});
this.player = player; this.player = player;
console.log('是否拿到第一次初始值呢', this.platform, typeof this.firstTime, this.firstTime) console.log('是否拿到第一次初始值呢', this.platform, typeof this.firstTime, this.firstTime)
// if (this.platform == 'ios') {
// this.player.one('timeupdate', () => {
// this.player.seek(this.firstTime);
// })
// } else {
// // if(player){
// this.player.seek(this.firstTime)
// // }
// }
clearInterval(this.videoTimer); clearInterval(this.videoTimer);
@@ -763,8 +735,6 @@
var that = this; var that = this;
that.curTime = parseInt(this.player.getCurrentTime()); that.curTime = parseInt(this.player.getCurrentTime());
that.curStatus = this.player.getStatus() that.curStatus = this.player.getStatus()
}, 1000); }, 1000);
this.$refs.videoContent4.click() this.$refs.videoContent4.click()
player.on('ready', function() { player.on('ready', function() {
@@ -777,9 +747,7 @@
this.player.on('playing', function() { this.player.on('playing', function() {
console.log('正在播放') console.log('正在播放')
}) })
this.player.on('ended', function() { this.player.on('ended', function() {
// console.log('that.curTime at line 242:', this.curTime)
// console.log('that.curStatus at line 210:', this.curStatus)
this.$refs.videoContent2.click() this.$refs.videoContent2.click()
}) })
}, },