31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import vlc
|
|
import time
|
|
import os
|
|
from logging_config import Logger
|
|
|
|
if __name__ == "__main__":
|
|
video_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'intro1.mp4')
|
|
Logger.info(f"[VLC TEST] Attempting to play video: {video_path}")
|
|
if not os.path.exists(video_path):
|
|
Logger.error(f"[VLC TEST] File does not exist: {video_path}")
|
|
exit(1)
|
|
instance = vlc.Instance('--no-osd', '--no-video-title-show', '--quiet', '--fullscreen')
|
|
player = instance.media_player_new()
|
|
media = instance.media_new(video_path)
|
|
player.set_media(media)
|
|
player.play()
|
|
Logger.info("[VLC TEST] player.play() called. Waiting for video to finish...")
|
|
# Wait for video to finish (max 30 seconds)
|
|
start = time.time()
|
|
while True:
|
|
state = player.get_state()
|
|
if state in (vlc.State.Ended, vlc.State.Error):
|
|
Logger.info(f"[VLC TEST] Playback ended with state: {state}")
|
|
break
|
|
if time.time() - start > 30:
|
|
Logger.warning("[VLC TEST] Timeout waiting for video to finish.")
|
|
break
|
|
time.sleep(0.2)
|
|
player.stop()
|
|
Logger.info("[VLC TEST] Done.")
|