EG/demo/test_video_fix.py
2025-12-12 16:16:15 +08:00

102 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
视频播放功能修复测试
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import loadPrcFileData
import sys
# 配置窗口
loadPrcFileData("", """
win-size 800 600
window-title 视频功能测试
""")
class VideoTest(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# 初始化属性以兼容 VideoManager
self.models = [] # 模型列表
print("🚀 开始视频功能测试...")
# 测试导入
try:
from video_integration import VideoManager
print("✅ 视频管理器导入成功")
except Exception as e:
print(f"❌ 视频管理器导入失败: {e}")
return
# 创建视频管理器
try:
self.video_manager = VideoManager(self)
print("✅ 视频管理器创建成功")
except Exception as e:
print(f"❌ 视频管理器创建失败: {e}")
return
# 测试创建动画屏幕
try:
screen = self.video_manager.create_video_screen(
pos=(0, 0, 2),
name="test_screen"
)
if screen:
print("✅ 动画屏幕创建成功")
else:
print("❌ 动画屏幕创建失败")
except Exception as e:
print(f"❌ 动画屏幕创建错误: {e}")
# 测试创建广告牌
try:
billboard = self.video_manager.create_video_billboard(
pos=(3, 0, 1),
name="test_billboard"
)
if billboard:
print("✅ 视频广告牌创建成功")
else:
print("❌ 视频广告牌创建失败")
except Exception as e:
print(f"❌ 视频广告牌创建错误: {e}")
# 测试创建全景视频
try:
spherical = self.video_manager.create_spherical_video(
pos=(-3, 0, 0),
radius=2,
name="test_spherical"
)
if spherical:
print("✅ 全景视频创建成功")
else:
print("❌ 全景视频创建失败")
except Exception as e:
print(f"❌ 全景视频创建错误: {e}")
# 等待几秒钟查看动画效果
print("\n🎬 测试完成!您应该看到:")
print(" - 左侧: 波纹动画屏幕")
print(" - 中间: 面向相机的广告牌")
print(" - 右侧: 全景动画球体")
print("\n按 ESC 键退出")
# 设置退出键
self.accept("escape", sys.exit)
# 设置相机
self.cam.setPos(0, -8, 2)
self.cam.lookAt(0, 0, 1)
def updateSceneTree(self):
"""空的场景树更新方法(用于兼容 VideoManager"""
pass
if __name__ == "__main__":
app = VideoTest()
app.run()