new video to new demo
This commit is contained in:
		
							parent
							
								
									a20ffbedf6
								
							
						
					
					
						commit
						424b9f3c12
					
				| @ -88,15 +88,15 @@ const connectedClients = new Map(); | |||||||
| // 视频映射配置
 | // 视频映射配置
 | ||||||
| const videoMapping = { | const videoMapping = { | ||||||
|   // 'say-6s-m-e': '1-m.mp4',
 |   // 'say-6s-m-e': '1-m.mp4',
 | ||||||
|   'default': 'bd-1.mp4', |   'default': 'chane.mp4', | ||||||
|   // 'say-5s-amplitude': '2.mp4',
 |   // 'say-5s-amplitude': '2.mp4',
 | ||||||
|   // 'say-5s-m-e': '4.mp4',
 |   // 'say-5s-m-e': '4.mp4',
 | ||||||
|   'say-5s-m-sw': 'd-0.mp4', |   // 'say-5s-m-sw': 'd-0.mp4',
 | ||||||
|   // 'say-3s-m-sw': '6.mp4',
 |   // 'say-3s-m-sw': '6.mp4',
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // 默认视频流配置
 | // 默认视频流配置
 | ||||||
| const DEFAULT_VIDEO = 'bd-1.mp4'; | const DEFAULT_VIDEO = 'chang.mp4'; | ||||||
| const INTERACTION_TIMEOUT = 10000; // 10秒后回到默认视频
 | const INTERACTION_TIMEOUT = 10000; // 10秒后回到默认视频
 | ||||||
| 
 | 
 | ||||||
| // 获取视频列表
 | // 获取视频列表
 | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ export const config = { | |||||||
|   audio: { |   audio: { | ||||||
|     model: 'speech-02-hd', |     model: 'speech-02-hd', | ||||||
|     voiceSetting: { |     voiceSetting: { | ||||||
|       voice_id: 'yantu-qinggang-3', |       voice_id: 'yantu-qinggang-demo2-male-4', | ||||||
|       speed: 1, |       speed: 1, | ||||||
|       vol: 1, |       vol: 1, | ||||||
|       pitch: 0, |       pitch: 0, | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ class WebRTCChat { | |||||||
|         this.mediaRecorder = null; |         this.mediaRecorder = null; | ||||||
|         this.audioChunks = []; |         this.audioChunks = []; | ||||||
|         this.videoMapping = {}; |         this.videoMapping = {}; | ||||||
|         this.defaultVideo = 'bd-1.mp4'; |         this.defaultVideo = 'chang.mp4'; | ||||||
|         this.currentVideoTag = 'default'; |         this.currentVideoTag = 'default'; | ||||||
|         this.currentVideo = null; |         this.currentVideo = null; | ||||||
|         this.videoStreams = new Map(); // 存储不同视频的MediaStream
 |         this.videoStreams = new Map(); // 存储不同视频的MediaStream
 | ||||||
| @ -429,7 +429,7 @@ class WebRTCChat { | |||||||
|     // 在应用初始化时预加载常用视频
 |     // 在应用初始化时预加载常用视频
 | ||||||
|     async preloadCommonVideos() { |     async preloadCommonVideos() { | ||||||
|         // 获取所有可能需要的视频
 |         // 获取所有可能需要的视频
 | ||||||
|         const videosToPreload = new Set(['bd-1.mp4']); |         const videosToPreload = new Set(['chang.mp4']); | ||||||
|          |          | ||||||
|         // 添加视频映射中的所有视频
 |         // 添加视频映射中的所有视频
 | ||||||
|         // Object.values(this.videoMapping).forEach(video => {
 |         // Object.values(this.videoMapping).forEach(video => {
 | ||||||
| @ -437,7 +437,7 @@ class WebRTCChat { | |||||||
|         // });
 |         // });
 | ||||||
|          |          | ||||||
|         // 特别确保添加了5.mp4(从日志看这是常用视频)
 |         // 特别确保添加了5.mp4(从日志看这是常用视频)
 | ||||||
|         videosToPreload.add('d-0.mp4'); |         // videosToPreload.add('d-0.mp4');
 | ||||||
|          |          | ||||||
|         // 并行预加载,提高效率
 |         // 并行预加载,提高效率
 | ||||||
|         const preloadPromises = Array.from(videosToPreload).map(async (videoFile) => { |         const preloadPromises = Array.from(videosToPreload).map(async (videoFile) => { | ||||||
|  | |||||||
| @ -68,16 +68,16 @@ async function processAudioQueue() { | |||||||
|       const sayName = 'say-5s-m-sw' |       const sayName = 'say-5s-m-sw' | ||||||
|       const targetVideo = 'd-0.mp4' |       const targetVideo = 'd-0.mp4' | ||||||
|       // 如果是第一个音频片段,触发视频切换
 |       // 如果是第一个音频片段,触发视频切换
 | ||||||
|       if (isFirstChunk && sayName != window.webrtcApp.currentVideoTag && window.webrtcApp && window.webrtcApp.switchVideoWithReplaceTrack) { |       // if (isFirstChunk && sayName != window.webrtcApp.currentVideoTag && window.webrtcApp && window.webrtcApp.switchVideoWithReplaceTrack) {
 | ||||||
|         try { |       //   try {
 | ||||||
|           console.log('--------------触发视频切换:', sayName); |       //     console.log('--------------触发视频切换:', sayName);
 | ||||||
|           window.webrtcApp.switchVideoWithReplaceTrack(targetVideo, 'audio', 'say-5s-m-sw'); |       //     window.webrtcApp.switchVideoWithReplaceTrack(targetVideo, 'audio', 'say-5s-m-sw');
 | ||||||
|           isFirstChunk = false; |       //     isFirstChunk = false;
 | ||||||
|           window.webrtcApp.currentVideoTag = sayName; |       //     window.webrtcApp.currentVideoTag = sayName;
 | ||||||
|         } catch (error) { |       //   } catch (error) {
 | ||||||
|           console.error('视频切换失败:', error); |       //     console.error('视频切换失败:', error);
 | ||||||
|         } |       //   }
 | ||||||
|       } |       // }
 | ||||||
|       await playAudioData(audioItem.audioData); |       await playAudioData(audioItem.audioData); | ||||||
|     } else { |     } else { | ||||||
|       // 等待一小段时间再检查
 |       // 等待一小段时间再检查
 | ||||||
| @ -89,11 +89,11 @@ async function processAudioQueue() { | |||||||
|   const text = 'default' |   const text = 'default' | ||||||
|   // await new Promise(resolve => setTimeout(resolve, 500));
 |   // await new Promise(resolve => setTimeout(resolve, 500));
 | ||||||
|   console.log("音频结束------------------------:", window.webrtcApp.currentVideoTag, isPlaying) |   console.log("音频结束------------------------:", window.webrtcApp.currentVideoTag, isPlaying) | ||||||
|   if (window.webrtcApp.currentVideoTag != text) { |   // if (window.webrtcApp.currentVideoTag != text) {
 | ||||||
|     isFirstChunk = true |   //   isFirstChunk = true
 | ||||||
|     window.webrtcApp.currentVideoTag = text |   //   window.webrtcApp.currentVideoTag = text
 | ||||||
|     window.webrtcApp.switchVideoWithReplaceTrack(window.webrtcApp.defaultVideo, 'audio', text); |   //   window.webrtcApp.switchVideoWithReplaceTrack(window.webrtcApp.defaultVideo, 'audio', text);
 | ||||||
|   } |   // }
 | ||||||
|   console.log('音频队列处理完成'); |   console.log('音频队列处理完成'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								videos/chang.mp4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								videos/chang.mp4
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user