Compare commits
2 Commits
78390a37de
...
ccd0a8bc34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccd0a8bc34 | ||
|
|
25ad982b5f |
17
src/index.js
17
src/index.js
@ -621,15 +621,17 @@ class WebRTCChat {
|
||||
try {
|
||||
this.logMessage(`开始平滑切换视频流: ${videoFile} (${type})`, 'info');
|
||||
|
||||
// 显示加载指示器
|
||||
this.showVideoLoading();
|
||||
// 检查是否已缓存,如果已缓存则不显示加载指示器
|
||||
const isCached = this.videoStreams.has(videoFile);
|
||||
if (!isCached) {
|
||||
this.showVideoLoading();
|
||||
}
|
||||
|
||||
// 确定当前活跃的视频元素和缓冲元素
|
||||
const currentVideo = this.activeVideoElement === 'main' ? this.recordedVideo : this.recordedVideoBuffer;
|
||||
const bufferVideo = this.activeVideoElement === 'main' ? this.recordedVideoBuffer : this.recordedVideo;
|
||||
|
||||
// 检查是否已缓存
|
||||
const isCached = this.videoStreams.has(videoFile);
|
||||
let newStream;
|
||||
|
||||
if (isCached) {
|
||||
@ -674,11 +676,13 @@ class WebRTCChat {
|
||||
bufferVideo.play().catch(onError);
|
||||
});
|
||||
|
||||
// 隐藏加载指示器
|
||||
this.hideVideoLoading();
|
||||
// 只有显示了加载指示器才隐藏
|
||||
if (!isCached) {
|
||||
this.hideVideoLoading();
|
||||
}
|
||||
|
||||
// 执行淡入淡出切换
|
||||
await this.performVideoTransition(currentVideo, bufferVideo);
|
||||
// await this.performVideoTransition(currentVideo, bufferVideo);
|
||||
|
||||
// 更新当前视频流和活跃元素
|
||||
this.currentVideoStream = newStream;
|
||||
@ -712,6 +716,7 @@ class WebRTCChat {
|
||||
|
||||
} catch (error) {
|
||||
this.logMessage(`平滑切换视频流失败: ${error.message}`, 'error');
|
||||
// 确保隐藏加载指示器
|
||||
this.hideVideoLoading();
|
||||
|
||||
// 如果切换失败,尝试回到默认视频
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user