xuqiaoying 3 лет назад
Родитель
Сommit
c9684ccc14
2 измененных файлов с 44 добавлено и 18 удалено
  1. 2 1
      http/http.js
  2. 42 17
      pages/live/index.vue

+ 2 - 1
http/http.js

@@ -2,7 +2,8 @@
 // const base_url = 'http://42.192.164.187:19005'  //test
 // const base_url = 'http://42.192.164.187:19005'  //test
 // export const base_url = 'http://api.xyyxt.net:19009'   //
 // export const base_url = 'http://api.xyyxt.net:19009'   //
 // export const base_url = 'https://test.xyyxt.net'   //预发布
 // export const base_url = 'https://test.xyyxt.net'   //预发布
-const base_url = 'http://192.168.1.7:5055'  //dev
+// const base_url = 'http://192.168.1.7:5055'  //dev
+export const base_url = 'http://120.79.166.78:19012' // 测试环境
 
 
 
 
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release

+ 42 - 17
pages/live/index.vue

@@ -70,14 +70,19 @@ import "@/static/public.css";
 				},
 				},
 				buyCourse: 1, // 是否购买课程:1是 0否
 				buyCourse: 1, // 是否购买课程:1是 0否
 				identification: '', // 标识
 				identification: '', // 标识
+				sectionType: 2, // 节类型 1录播 2直播 3回放	
+				vid: '', // 回放的id
 			}
 			}
 		},
 		},
 		mounted() {
 		mounted() {
 			
 			
 			console.log('直播间参数',this.$route.query)
 			console.log('直播间参数',this.$route.query)
-			const { buyCourse, ident } = this.$route.query
+			const { buyCourse, ident, sectionType, vid } = this.$route.query
+			console.log('sectionType:', sectionType, vid)
 			this.buyCourse = buyCourse
 			this.buyCourse = buyCourse
 			this.identification = ident
 			this.identification = ident
+			this.sectionType = sectionType || 2
+			this.vid = vid
 			this.sectionId = this.$route.query.sectionId;
 			this.sectionId = this.$route.query.sectionId;
 			this.goodsId = this.$route.query.goodsId;
 			this.goodsId = this.$route.query.goodsId;
 			this.courseId = this.$route.query.courseId;
 			this.courseId = this.$route.query.courseId;
@@ -97,7 +102,7 @@ import "@/static/public.css";
 				uni.setStorageSync('token',token)
 				uni.setStorageSync('token',token)
 			}
 			}
 			this.playVideo();
 			this.playVideo();
-			if(this.sectionId) {
+			if(this.sectionId && this.sectionType != 3) {
 				this.studyRecordGetLastLive();
 				this.studyRecordGetLastLive();
 			}
 			}
 			
 			
@@ -138,7 +143,7 @@ import "@/static/public.css";
 							channelId: this.channelId,
 							channelId: this.channelId,
 						}
 						}
 				}).then( res => {
 				}).then( res => {
-					console.log(res,'res')
+					if (res.data.code == 200) {
 					this.sign = res.data.data.sign;
 					this.sign = res.data.data.sign;
 					this.token = res.data.data.token;
 					this.token = res.data.data.token;
 					this.mediaChannelKey = res.data.data.mediaChannelKey;
 					this.mediaChannelKey = res.data.data.mediaChannelKey;
@@ -146,6 +151,13 @@ import "@/static/public.css";
 					this.appId = res.data.data.appId;
 					this.appId = res.data.data.appId;
 					
 					
 					this.loadPlayerzb();
 					this.loadPlayerzb();
+					} else {
+						uni.showToast({
+							title: res.data.msg,
+							icon: 'none'
+						})
+					}
+				}).catch((err) => {
 				})
 				})
 			},
 			},
 			
 			
@@ -172,7 +184,8 @@ import "@/static/public.css";
 						videoCurrentTime: parseInt(
 						videoCurrentTime: parseInt(
 							 2
 							 2
 						),
 						),
-						status:status
+						status:status,
+						fromPlat: 1,
 					},
 					},
 					method:'POST'
 					method:'POST'
 				})
 				})
@@ -285,6 +298,7 @@ import "@/static/public.css";
 					},
 					},
 				});
 				});
 				
 				
+				// 监听流状态变化刷新播放器
 			 this.plv.liveSdk.on(PolyvLiveSdk.EVENTS.STREAM_UPDATE, (event,status)=> {
 			 this.plv.liveSdk.on(PolyvLiveSdk.EVENTS.STREAM_UPDATE, (event,status)=> {
 				 console.log(status,'STREAM_UPDATE')
 				 console.log(status,'STREAM_UPDATE')
 				 if(status == 'end') {
 				 if(status == 'end') {
@@ -298,20 +312,31 @@ import "@/static/public.css";
 
 
 
 
 				// 第四步:监听频道信息读取完成事件,初始化播放器
 				// 第四步:监听频道信息读取完成事件,初始化播放器
+				let options = {
+					pptEl: els.pptEl,
+					el: els.playerEl,
+					switchPlayer: true,
+					controllerPosition: "ppt",
+					pptNavBottom: "180px",
+					controllerPosition: "player",
+					fixedController: true,
+					barrage: true,
+					defaultBarrageStatus: true,
+					controllerEl: els.controllerEl,
+					autoplay: true, // 设置自动播放
+				}
+				if (this.sectionType == 3) {
+					// 回放模式需要fileId、url、sessionId
+					// fileId: undefined, //ppt数据id,回放模式必填
+					// url: undefined,  // 回放视频链接,回放模式必填
+					// sessionId: undefined, // 回放场次id,回放模式必填
+					// vid: undefined,  // 回放id,回放模式下传入该参数,可不传fileId、url、sessionId
+					options.type = 'vod',
+					options.vid = this.vid
+				}
+				console.log('options', options)
 				this.plv.liveSdk.on(PolyvLiveSdk.EVENTS.CHANNEL_DATA_INIT, (event, data) => {
 				this.plv.liveSdk.on(PolyvLiveSdk.EVENTS.CHANNEL_DATA_INIT, (event, data) => {
-					this.plv.liveSdk.setupPlayer({
-						pptEl: els.pptEl,
-						el: els.playerEl,
-						switchPlayer: true,
-						controllerPosition: "ppt",
-						pptNavBottom: "180px",
-						controllerPosition: "player",
-						fixedController: true,
-						barrage: true,
-						defaultBarrageStatus: true,
-						controllerEl: els.controllerEl,
-						autoplay: true, // 设置自动播放
-					});
+					this.plv.liveSdk.setupPlayer(options);
 
 
 					this.plv.liveSdk.player.on("switchPlayer", () => {
 					this.plv.liveSdk.player.on("switchPlayer", () => {
 						this.changeState = !this.changeState;
 						this.changeState = !this.changeState;