package cz.jzitnik.screens.scenes;

import cz.jzitnik.events.KeyboardPressEvent;
import cz.jzitnik.events.MouseAction;
import cz.jzitnik.screens.VideoPlayScreen;
import cz.jzitnik.sound.SoundPlayer;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public final class VideoSceneWithAudio extends VideoPlayScreen {
    private final SoundPlayer soundPlayer = new SoundPlayer();
    private final String audioPath;

    public VideoSceneWithAudio(String videoPath, String audioPath) {
        super(videoPath);
        this.audioPath = audioPath;
    }

    @Override
    public void fullRender() {
        if (!isRenderedAlready) {
            isRenderedAlready = true;
            playSound();
            render();
            this.soundPlayer.stopCurrentSound();
        }
    }

    private void playSound() {
        new Thread(() -> soundPlayer.playSound(audioPath, 100, 100)).start();
    }

    @Override
    public void handleMouseAction(MouseAction event) {

    }

    @Override
    public void handleKeyboardAction(KeyboardPressEvent event) {

    }
}
