安卓可以播

This commit is contained in:
@fawn-nine
2024-07-20 10:44:32 +08:00
parent 719f90889c
commit ed130e8dc5
7 changed files with 1484 additions and 23 deletions

View File

@@ -48,6 +48,7 @@
</view>
</template>
<script>
import store from "@/store/index.js";
import $http from "@/config/requestConfig.js";
import {
mapState,
@@ -89,7 +90,12 @@
},
},
// //页面显示
mounted() {},
mounted() {
clearInterval(this.$store.state.videoTimer);
clearInterval(this.videoTimer);
this.videoTimer = null;
plus.screen.lockOrientation("portrait-primary");
},
async onUnload() {
uni.navigateTo({
url: "/pages/curriculum/order/curriculum/back",
@@ -221,22 +227,28 @@
this.firstTime = 0;
}
}
this.currentTime = this.firstTime;
// this.currentTime = this.firstTime;
console.log(this.firstTime, "这是第一次播放时长222",this.noRecored);
await this.setVideoTime();
uni.setStorageSync("videoOssList", JSON.stringify(list));
if (this.currentVideo.type == 0 || this.currentVideo.type == 2) {
await this.playVideo();
}
console.log(this.firstTime, "这是第一次播放时长");
this.isSetFirstTime = true;
this.isSetFirstTime = true;
if (this.currentVideo.type == 0 || this.currentVideo.type == 2) {
await this.playVideo();
}
}
},
async playVideo(e) {
this.videoContext = uni.createVideoContext("videoId", this);
this.videoContext.seek(this.firstTime);
if (this.isSetFirstTime) {
setTimeout((res) => {
this.videoContext.seek(this.firstTime);
this.setVideoFirtsetTime();
}, 100);
}
// this.videoContext.requestFullScreen();
},
recordTime(data) {
@@ -283,6 +295,7 @@
},
})
.then((res) => {
if (this.currentVideo.type == 1) {
var playAuth = res.video.playAuth.replace(/=/g, "");
this.videoData = {
@@ -314,8 +327,10 @@
var data = list.find((e) => e.id == this.videoData.id);
this.currentTime = data.time;
console.log('this.currentTime at line 这是结束的时候掉的存储视频:', this.currentTime)
await this.setVideoTime();
clearInterval(this.$store.state.videoTimer);
this.timer = null;
await this.setVideoTime();
},
setVideoTime(time) {
let thisBlur = JSON.parse(this.noRecored)
@@ -329,7 +344,7 @@
videoId: this.videoData.id,
position: this.currentTime, //秒数
};
return
$http
.request({
url: `sociology/course/saveCoursePosition`,
@@ -354,6 +369,19 @@
delta: 1,
});
},
async setVideoFirtsetTime(time) {
this.currentTime = this.firstTime;
console.log("这里准备开始设置播放时间:", this.currentTime);
store.commit(
"setVideoTimer",
setInterval(async () => {
// if (this.currentTime) {
await this.setVideoTime();
// }
}, 60000)
);
// }, 5000);
},
},
created() {},
@@ -394,7 +422,6 @@
watch: {
curTime(val) {
console.log('val at line 这是真正的时长:', val)
if (this.curTime !== null && this.curStatus !== null) {
@@ -847,9 +874,6 @@
},
loadWebPlayerSDK() {
return new Promise((resolve, reject) => {
const s_tag = document.createElement('script'); // 引入播放器js
s_tag.type = 'text/javascript';
s_tag.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/aliplayer-min.js';