安卓可以播

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

@@ -12,13 +12,19 @@
"src" : "图片路径" "src" : "图片路径"
} }
], ],
"versionName" : "1.0.05", "versionName" : "1.0.07",
"versionCode" : 100, "versionCode" : 1007,
"app-plus" : { "app-plus" : {
"nvueCompiler" : "weex", "nvueCompiler" : "weex",
"compatible" : { "compatible" : {
"ignoreVersion" : true "ignoreVersion" : true
}, },
"screenOrientation" : [
"portrait-primary",
"portrait-secondary",
"landscape-primary",
"landscape-secondary"
],
"privacy" : { "privacy" : {
"prompt" : "template", "prompt" : "template",
"template" : { "template" : {

View File

@@ -366,12 +366,21 @@
} }
}, },
{ {
// ios课程播放
"path": "pages/course/chapterDetail", "path": "pages/course/chapterDetail",
"style": { "style": {
"navigationBarTitleText": "章节详情", "navigationBarTitleText": "章节详情",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{
// Andriod课程播放
"path": "pages/course/chapterDetailAndorid",
"style": {
"navigationBarTitleText": "章节详情",
"enablePullDownRefresh": true
}
},
{ {
"path": "pages/course/courseSet", "path": "pages/course/courseSet",
"style": { "style": {

View File

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

View File

@@ -5,14 +5,14 @@
:src="videoData.type==1?videoData.m3u8Url:videoData.videoUrl" autoplay="true" duration="" :src="videoData.type==1?videoData.m3u8Url:videoData.videoUrl" autoplay="true" duration=""
enable-danmu="true" :loop="true" :title="videoTitle" @click="" initial-time="" direction="-90" show-mute-btn="true" enable-danmu="true" :loop="true" :title="videoTitle" @click="" initial-time="" direction="-90" show-mute-btn="true"
@play="onstart" @pause="onpause" @ended="onfinish" @error="onfail" @waiting="waiting" @play="onstart" @pause="onpause" @ended="onfinish" @error="onfail" @waiting="waiting"
@timeupdate="timeupdate" @fullscreenchange="fullscreenchange"> @timeupdate="timeupdate" @fullscreenchange="fullscreenchange" >
<cover-view v-show="speedState && !mode" style="position: absolute; padding: 10rpx !important; background-color:rgba(0, 0, 0, .8); color: #fff; top: 30rpx; right: 30rpx;" <!-- <cover-view v-show="speedState && !mode" style="position: absolute; padding: 10rpx !important; background-color:rgba(0, 0, 0, .8); color: #fff; top: 30rpx; right: 30rpx;"
@click="beisuClick()">{{beisuText}}</cover-view> @click="beisuClick()">{{beisuText}}</cover-view>
<cover-view v-show="mode && speedState" style="position: absolute; color: #fff; top: 30rpx; right: 30rpx;"> <cover-view v-show="mode && speedState" style="position: absolute; color: #fff; top: 30rpx; right: 30rpx;">
<cover-view class="speedList" v-for="(item, index) in playbackRateList" :key="index"> <cover-view class="speedList" v-for="(item, index) in playbackRateList" :key="index">
<cover-view :class="['speedItem',speedIndex == index ? 'active' : '']" @click="doubleSpeed(item.value, index)">x{{item.value}}</cover-view> <cover-view :class="['speedItem',speedIndex == index ? 'active' : '']" @click="doubleSpeed(item.value, index)">x{{item.value}}</cover-view>
</cover-view> </cover-view>
</cover-view> </cover-view> -->
</video> </video>
<!-- <div <!-- <div
@@ -177,7 +177,7 @@
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.screen.lockOrientation("portrait-primary"); //锁死屏幕方向为竖屏 plus.screen.lockOrientation("portrait-primary"); //锁死屏幕方向为竖屏
clearTimeout(this.beisuShowTimer) clearTimeout(this.beisuShowTimer)
// plus.screen.lockOrientation("portrait-primary"); plus.screen.lockOrientation("portrait-primary");
// #endif // #endif
// this.player.dispose(); // this.player.dispose();
@@ -225,6 +225,12 @@
}, },
fullscreenchange(e) { fullscreenchange(e) {
console.log("fullscreenchange全屏:" + JSON.stringify(e)); console.log("fullscreenchange全屏:" + JSON.stringify(e));
if(!e.detail.fullScreen){
console.log('取消全屏');
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary');
// #endif
}
}, },
waiting(e) { waiting(e) {
console.log("waiting:" + JSON.stringify(e)); console.log("waiting:" + JSON.stringify(e));

File diff suppressed because it is too large Load Diff

View File

@@ -481,7 +481,8 @@
goodsList: "sociology/product/getProductListForCourse", goodsList: "sociology/product/getProductListForCourse",
startStudyForMF: "sociology/course/startStudyForMF", startStudyForMF: "sociology/course/startStudyForMF",
}, },
isAndorid: true isAndorid: true,
oprateOsName:'',
}; };
}, },
//第一次加载 //第一次加载
@@ -557,7 +558,8 @@
getOS() { getOS() {
let oprateOs = ""; let oprateOs = "";
oprateOs = uni.getSystemInfoSync().platform; oprateOs = uni.getSystemInfoSync().platform;
// console.log(oprateOs) this.oprateOsName = uni.getSystemInfoSync().platform;
console.log('oprateOs',oprateOs)
if (oprateOs == "android") { if (oprateOs == "android") {
this.isAndorid = true; this.isAndorid = true;
} else { } else {
@@ -637,13 +639,20 @@
async gotoDetail(v, courseIndex) { async gotoDetail(v, courseIndex) {
console.log("准备进入学习页面", v); console.log("准备进入学习页面", v);
this.currentCateIndex = courseIndex; this.currentCateIndex = courseIndex;
let _myurl = ''
if(this.oprateOsName == 'ios'){
_myurl = '/pages/course/chapterDetail'
}else{
// h5 和安卓
_myurl = '/pages/course/chapterDetailAndorid'
}
if (this.librayList[this.curIndex].isBuy == 1 || v.isAudition == 1 || if (this.librayList[this.curIndex].isBuy == 1 || v.isAudition == 1 ||
this.vip.type != "0") { this.vip.type != "0") {
let noRecored = false let noRecored = false
v.isAudition == 1 && this.userMsg.vip == 0 && this.librayList[this.curIndex].isBuy == 0 ? v.isAudition == 1 && this.userMsg.vip == 0 && this.librayList[this.curIndex].isBuy == 0 ?
noRecored = true : '' noRecored = true : ''
uni.navigateTo({ uni.navigateTo({
url: `/pages/course/chapterDetail?navTitle=${this.pageTitle}&title=${v.title}&id=${v.id}&conditions=${v.conditions}&noRecored=${noRecored}`, url: `${_myurl}?navTitle=${this.pageTitle}&title=${v.title}&id=${v.id}&conditions=${v.conditions}&noRecored=${noRecored}`,
}); });
} else { } else {
this.$commonJS.showToast("请先购买课程"); this.$commonJS.showToast("请先购买课程");

Binary file not shown.