|
@@ -66,20 +66,6 @@
|
|
|
>
|
|
|
</cover-view>
|
|
|
</view>
|
|
|
- <view
|
|
|
- class="video_box"
|
|
|
- style="width: 100%; height: 421rpx"
|
|
|
- v-if="playChannelId > 0"
|
|
|
- >
|
|
|
- <player
|
|
|
- class="plv-mp-demo-player"
|
|
|
- :videoOption="videoOption"
|
|
|
- :page-gesture="true"
|
|
|
- :vslide-gesture="true"
|
|
|
- :vslide-gesture-in-fullscreen="true"
|
|
|
- @onLiveStatusChange="playerLiveStatusChange"
|
|
|
- />
|
|
|
- </view>
|
|
|
</view>
|
|
|
<view class="course_name">
|
|
|
<view class="course_titles">
|
|
@@ -730,7 +716,6 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
hasStart: false,
|
|
|
- channelItem: null,
|
|
|
lockTimer: null,
|
|
|
orderGoodsId: 0,
|
|
|
noticeShow: false,
|
|
@@ -739,9 +724,6 @@ export default {
|
|
|
seekTime: "",
|
|
|
toastTimer: null,
|
|
|
videoToastShow: false,
|
|
|
- initLiveOk: false,
|
|
|
- livePlay: false, //是否正在播放直播,不含暂停
|
|
|
- liveDuration: 0, //直播观看时长
|
|
|
videoOption: {
|
|
|
mode: "live",
|
|
|
uid: "",
|
|
@@ -1065,20 +1047,6 @@ export default {
|
|
|
this.moduleId = arr[0];
|
|
|
this.chapterId = arr[1];
|
|
|
});
|
|
|
- uni.$on("getChannel", (item) => {
|
|
|
- //清除录播
|
|
|
- this.hasStart = false;
|
|
|
- this.$store.commit("setPlayVID", { playVID: null });
|
|
|
-
|
|
|
- this.moduleId = item.moduleId;
|
|
|
- this.chapterId = item.chapterId;
|
|
|
- this.$store.commit("setPlaySectionId", {
|
|
|
- playSectionId: item.sectionId || item.menuId,
|
|
|
- });
|
|
|
- this.getPhotoLastRecord();
|
|
|
- this.playChannel(item);
|
|
|
- this.channelItem = item;
|
|
|
- });
|
|
|
uni.$on("isRebuild", (item) => {
|
|
|
this.isRebuild = item;
|
|
|
});
|
|
@@ -1535,129 +1503,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- getLiveUid(channelId) {
|
|
|
- let self = this;
|
|
|
- return new Promise((resolve) => {
|
|
|
- let data = {
|
|
|
- channelId: channelId,
|
|
|
- orderGoodsId: this.orderGoodsId,
|
|
|
- };
|
|
|
- self.$api.polyvSign(data).then((res) => {
|
|
|
- resolve(res.data.data);
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- timeEventLiving() {
|
|
|
- if (plv != null) {
|
|
|
- if (this.livePlay) {
|
|
|
- this.liveDuration = this.liveDuration + 1; //每隔1秒
|
|
|
- if (this.liveDuration == 2) {
|
|
|
- //直播第2秒拍照
|
|
|
- // console.log(this.channelItem)
|
|
|
- // console.log(this.photoHistoryList,'this.photoHistoryList')
|
|
|
- if (
|
|
|
- this.goodsPhotographConfig &&
|
|
|
- this.goodsPhotographConfig.livephotograph == 1 &&
|
|
|
- this.channelItem.learning != 1 &&
|
|
|
- this.photoHistoryList.length == 0
|
|
|
- ) {
|
|
|
- //开启直播拍照
|
|
|
- this.openPhoto();
|
|
|
- } else {
|
|
|
- this.postStudyRecord(0);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- playerLiveStatusChange(e) {
|
|
|
- const status = e.detail.status;
|
|
|
- // console.log("直播状态", status);
|
|
|
- if (status === "live") {
|
|
|
- // console.log("开始直播");
|
|
|
- //开始播放
|
|
|
- if (this.timer) {
|
|
|
- clearInterval(this.timer);
|
|
|
- }
|
|
|
- this.livePlay = true;
|
|
|
- this.timer = setInterval(this.timeEventLiving, 1000); //定时器
|
|
|
- }
|
|
|
- if (status === "end") {
|
|
|
- this.hasStart = false;
|
|
|
- if (this.livePlay) {
|
|
|
- //只有播放过的结束才提交,避免未开播触发结束
|
|
|
- this.postStudyRecord(1);
|
|
|
- }
|
|
|
- // console.log("结束直播");
|
|
|
- this.livePlay = false;
|
|
|
- // 未开始
|
|
|
- }
|
|
|
- },
|
|
|
- closePlv() {
|
|
|
- if (plv) {
|
|
|
- plv.destroy();
|
|
|
- }
|
|
|
- },
|
|
|
- playChannel(item) {
|
|
|
- if (this.timer) {
|
|
|
- clearInterval(this.timer);
|
|
|
- }
|
|
|
- this.startStatus = true;
|
|
|
- this.initLive();
|
|
|
- },
|
|
|
- setLiveOption(status) {
|
|
|
- const { userId, channelId, recordFileSimpleModel, playbackEnabled } =
|
|
|
- this.detail;
|
|
|
- const playRecordFile =
|
|
|
- playbackEnabled && recordFileSimpleModel && status === "end";
|
|
|
-
|
|
|
- // if(this.channelItem.sectionType == 3) { //回放
|
|
|
-
|
|
|
- // // this.videoOption = {
|
|
|
- // // mode: "live",
|
|
|
- // // uid: this.liveObj.uid, //this.playChannelId egsxlptzdq
|
|
|
- // // cid: this.playChannelId,
|
|
|
- // // openId: this.userInfo.userAccount,
|
|
|
- // // isAutoChange: false,
|
|
|
- // // forceVideo: false,
|
|
|
- // // };
|
|
|
- // } else { //直播
|
|
|
-
|
|
|
- this.videoOption = {
|
|
|
- mode: "live",
|
|
|
- uid: this.liveObj.uid, //this.playChannelId egsxlptzdq
|
|
|
- cid: this.playChannelId,
|
|
|
- openId: this.userInfo.userAccount,
|
|
|
- isAutoChange: false,
|
|
|
- forceVideo: false,
|
|
|
- };
|
|
|
- // }
|
|
|
- },
|
|
|
- async initLive() {
|
|
|
- this.liveObj = await this.getLiveUid(this.playChannelId);
|
|
|
- this.initLiveOk = true;
|
|
|
- let optionsData = {};
|
|
|
- optionsData.mode = "live";
|
|
|
- optionsData.forceVideo = false;
|
|
|
- optionsData.channelId = this.playChannelId; // 频道ID '2553128'
|
|
|
- optionsData.openId = this.userInfo.userAccount; // 用户openId this.userInfo.userAccount 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ'
|
|
|
- optionsData.userId = this.liveObj.uid; // 2.0.0及以上版本的demo需要使用 userId 设置学员唯一id 'egsxlptzdq'
|
|
|
- let self = this;
|
|
|
- this.closePlv();
|
|
|
- plv.init(optionsData).then(({ detail, chat }) => {
|
|
|
- self.liveDetail = detail;
|
|
|
-
|
|
|
- // 设置mode为live的videoOption
|
|
|
- this.setLiveOption();
|
|
|
- if (detail.isPPT) {
|
|
|
- chat.on(chat.events.SLICESTART, () => {
|
|
|
- // 开始直播
|
|
|
- });
|
|
|
- } else {
|
|
|
- plv.api.getOrdinaryLiveStatus(detail.stream);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
openSetting(res) {
|
|
|
// console.log(res, 98);
|
|
|
},
|