|  | @ -60,7 +60,9 @@ export async function openVideoStream(container, { camId, url } = {}) { | 
			
		
	
		
		
			
				
					|  |  |   player.load(); |  |  |   player.load(); | 
			
		
	
		
		
			
				
					|  |  |   player.play(); |  |  |   player.play(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |   player.on(flvJs.Events.ERROR, (e) => {}); |  |  |   player.on(flvJs.Events.ERROR, (errorType, errorDetails, errorInfo) => { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |     console.error('video errorInfo', errorInfo); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   return player; |  |  |   return player; | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | @ -98,6 +100,8 @@ export class HttpLivePlayer { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   // 解码 帧
 |  |  |   // 解码 帧
 | 
			
		
	
		
		
			
				
					|  |  |   lastDecodedFrames; |  |  |   lastDecodedFrames; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   retryCount = 0; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   maxRetries = 3; // 最大重试次数
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   constructor(container, options) { |  |  |   constructor(container, options) { | 
			
		
	
		
		
			
				
					|  |  |     this.container = container; |  |  |     this.container = container; | 
			
		
	
	
		
		
			
				
					|  | @ -106,6 +110,9 @@ export class HttpLivePlayer { | 
			
		
	
		
		
			
				
					|  |  |     getUrl(options).then((url) => { |  |  |     getUrl(options).then((url) => { | 
			
		
	
		
		
			
				
					|  |  |       this.url = url; |  |  |       this.url = url; | 
			
		
	
		
		
			
				
					|  |  |       this.initLiveVideo(); |  |  |       this.initLiveVideo(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     }).catch(error => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       console.error('获取URL失败:', error); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       Message.error('无法获取视频流URL'); | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -118,11 +125,18 @@ export class HttpLivePlayer { | 
			
		
	
		
		
			
				
					|  |  |     this.player.destroy(); |  |  |     this.player.destroy(); | 
			
		
	
		
		
			
				
					|  |  |     this.player = null; |  |  |     this.player = null; | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |   clearMediaElementErrors() { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |     if (this.container.error) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       console.error('Media element is in an error state:', this.container.error); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       this.container.error = null; // 清除错误状态
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					|  |  |   initLiveVideo() { |  |  |   initLiveVideo() { | 
			
		
	
		
		
			
				
					|  |  |     this.destroy(); |  |  |     this.destroy(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     this.clearMediaElementErrors(); // 清除媒体元素的错误状态
 | 
			
		
	
		
		
			
				
					|  |  |     this.player = null; |  |  |     this.player = null; | 
			
		
	
		
		
			
				
					|  |  |     this.lastDecodedFrames = null; |  |  |     this.lastDecodedFrames = null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     this.retryCount = 0; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     if (!this.url) return; |  |  |     if (!this.url) return; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -170,10 +184,13 @@ export class HttpLivePlayer { | 
			
		
	
		
		
			
				
					|  |  |       // Message.warning(
 |  |  |       // Message.warning(
 | 
			
		
	
		
		
			
				
					|  |  |       //   `视频流加载失败, ${ErrorTypesCn[errorType] || "其他错误"}`
 |  |  |       //   `视频流加载失败, ${ErrorTypesCn[errorType] || "其他错误"}`
 | 
			
		
	
		
		
			
				
					|  |  |       // );
 |  |  |       // );
 | 
			
		
	
		
		
			
				
					
					|  |  |       let self = this; |  |  |       if (this.retryCount < this.maxRetries) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       setTimeout(() => { |  |  |         this.retryCount++; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         self.initLiveVideo(); |  |  |         this.initLiveVideo(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       }, 300000); |  |  |       } else { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         Message.error(`视频流加载失败,已达到最大重试次数。${ErrorTypesCn[errorType] || "其他错误"}`); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.destroy(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     // 视频断流
 |  |  |     // 视频断流
 | 
			
		
	
	
		
		
			
				
					|  | @ -182,6 +199,7 @@ export class HttpLivePlayer { | 
			
		
	
		
		
			
				
					|  |  |         this.lastDecodedFrames = res.decodedFrames; |  |  |         this.lastDecodedFrames = res.decodedFrames; | 
			
		
	
		
		
			
				
					|  |  |       } else { |  |  |       } else { | 
			
		
	
		
		
			
				
					|  |  |         this.lastDecodedFrames = 0; |  |  |         this.lastDecodedFrames = 0; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.initLiveVideo(); // 重置解码帧计数器,防止假死
 | 
			
		
	
		
		
			
				
					|  |  |         // this.destroy();
 |  |  |         // this.destroy();
 | 
			
		
	
		
		
			
				
					|  |  |         // this.initLiveVideo();
 |  |  |         // this.initLiveVideo();
 | 
			
		
	
		
		
			
				
					|  |  |       } |  |  |       } | 
			
		
	
	
		
		
			
				
					|  | 
 |