Browse Source

Merge branch 'master' of https://gitee.com/he2802/saas_applet

Tang 3 years ago
parent
commit
c4774dc07e
1 changed files with 23 additions and 4 deletions
  1. 23 4
      pages2/course/detail.vue

+ 23 - 4
pages2/course/detail.vue

@@ -17,6 +17,8 @@
 						:playbackRate="playbackRate"
 						:isAllowSeek="isAllowSeek"
 						:autoplay="autoplay"
+						:startTime="startTime"
+						@statechange="onStateChange"
 					></polyv-player>
 				</view>
 				<view style="padding:20rpx;height: 120rpx;">
@@ -110,7 +112,8 @@ export default {
 			autoplay:true,
 			listenConfigList:[],
 			listenSecond:0,
-			timer:null
+			timer:null,
+			startTime:0
 		};
 	},
 	onUnload() {
@@ -140,17 +143,33 @@ export default {
 				if(this.timer){
 					clearInterval(this.timer);
 				}
-				this.timer = setInterval(this.timeEvent, 2000);//定时器
-				this.vid = item.recordingUrl
+				 if(this.vid){
+					 //切换视频
+					 var polyvPlayerContext = this.selectComponent('#playerVideo');
+					 polyvPlayerContext.changeVid(item.recordingUrl)
+				 }else{
+					 this.vid = item.recordingUrl
+				 }
+				
 				this.startStatus = true
+				this.startTime = 0
 			}else{
-				console.log(this.listenSecond,333)
 				this.$u.toast('试听配置错误');
 			}
 			
 		});
 	},
 	methods: {
+		onStateChange(newstate, oldstate) {
+			if (newstate.detail.newstate == 'playing') {
+				//开始播放
+				if(this.timer){
+					clearInterval(this.timer);
+				}
+				this.timer = setInterval(this.timeEvent, 2000);//定时器
+			}
+			
+		},
 		closePlay(){
 			this.vid = ""
 			this.startStatus = false