89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
// 视频播放队列系统测试
|
|
// 这个文件用于测试新的视频播放逻辑
|
|
|
|
export class VideoQueueTester {
|
|
constructor(webrtcApp) {
|
|
this.webrtcApp = webrtcApp;
|
|
}
|
|
|
|
// 测试视频队列功能
|
|
async testVideoQueue() {
|
|
console.log('开始测试视频播放队列系统...');
|
|
|
|
// 测试1: 添加视频到队列
|
|
await this.testAddToQueue();
|
|
|
|
// 测试2: 测试视频播放完成等待
|
|
await this.testWaitForVideoFinish();
|
|
|
|
// 测试3: 测试音频视频同步
|
|
await this.testAudioVideoSync();
|
|
|
|
console.log('视频播放队列系统测试完成');
|
|
}
|
|
|
|
// 测试添加视频到队列
|
|
async testAddToQueue() {
|
|
console.log('测试1: 添加视频到队列');
|
|
|
|
// 清空队列
|
|
this.webrtcApp.videoQueue = [];
|
|
|
|
// 添加测试视频
|
|
await this.webrtcApp.addToVideoQueue('5.mp4', 'test', '测试视频1');
|
|
await this.webrtcApp.addToVideoQueue('s-1.mp4', 'test', '测试视频2');
|
|
|
|
console.log(`队列长度: ${this.webrtcApp.videoQueue.length}`);
|
|
console.log('队列内容:', this.webrtcApp.videoQueue);
|
|
}
|
|
|
|
// 测试等待视频播放完成
|
|
async testWaitForVideoFinish() {
|
|
console.log('测试2: 等待视频播放完成');
|
|
|
|
// 模拟视频播放状态
|
|
this.webrtcApp.isVideoPlaying = true;
|
|
|
|
// 模拟视频播放完成
|
|
setTimeout(() => {
|
|
this.webrtcApp.isVideoPlaying = false;
|
|
console.log('模拟视频播放完成');
|
|
}, 2000);
|
|
|
|
console.log('等待视频播放完成...');
|
|
await this.webrtcApp.waitForCurrentVideoToFinish();
|
|
console.log('视频播放完成等待测试通过');
|
|
}
|
|
|
|
// 测试音频视频同步
|
|
async testAudioVideoSync() {
|
|
console.log('测试3: 音频视频同步');
|
|
|
|
// 模拟音频播放开始
|
|
window.isPlaying = true;
|
|
|
|
// 添加视频到队列
|
|
await this.webrtcApp.addToVideoQueue('5.mp4', 'audio', '音频同步测试');
|
|
|
|
// 模拟音频播放结束
|
|
setTimeout(() => {
|
|
window.isPlaying = false;
|
|
console.log('模拟音频播放结束');
|
|
}, 3000);
|
|
|
|
console.log('音频视频同步测试完成');
|
|
}
|
|
|
|
// 运行所有测试
|
|
async runAllTests() {
|
|
try {
|
|
await this.testVideoQueue();
|
|
console.log('所有测试通过!');
|
|
} catch (error) {
|
|
console.error('测试失败:', error);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 导出测试类
|
|
export default VideoQueueTester;
|