#!/bin/bash
# Test integrated player continuous demo with all data

set -e

VIDEO=/tmp/charade_audio.wav
ASR=/tmp/asr_small.json
ASRX=/tmp/asrx_charade_optimized.json
FACE=/tmp/face_long.json
POSE=/tmp/pose_long.json

echo "Testing Integrated Player - Continuous Demo"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# Check all files
if [ ! -f "$VIDEO" ]; then
	echo "⚠️  Video file not found: $VIDEO"
	exit 1
fi

if [ ! -f "$ASR" ]; then
	echo "⚠️  ASR file not found: $ASR"
	exit 1
fi

if [ ! -f "$ASRX" ]; then
	echo "⚠️  ASRX file not found: $ASRX"
	exit 1
fi

if [ ! -f "$FACE" ]; then
	echo "⚠️  Face file not found: $FACE"
	exit 1
fi

if [ ! -f "$POSE" ]; then
	echo "⚠️  Pose file not found: $POSE"
	exit 1
fi

echo "✅ All files found"
echo

echo "Data summary:"
echo "  ASR segments: $(jq '.segments | length' "$ASR")"
echo "  ASRX segments: $(jq '.segments | length' "$ASRX")"
echo "  Speakers: $(jq '.speaker_stats | keys | length' "$ASRX")"
echo "  Face frames: $(jq '.frames | length' "$FACE")"
echo "  Pose frames: $(jq '.frames | length' "$POSE")"
echo

echo "Running continuous demo..."
echo "  SPACE - Pause/Resume"
echo "  Q     - Quit"
echo

./target/release/integrated_player \
	--video "$VIDEO" \
	--asr "$ASR" \
	--asrx "$ASRX" \
	--face "$FACE" \
	--pose "$POSE" \
	--continuous-demo
