<?php

namespace MovieEngine\Admin\Player\Tabs;

if (! defined("ABSPATH")) {
    exit; // Exit if accessed directly
}

class AudioTab {

    public static function render($options) {
?>
        <input type="hidden" name="movie_engine_player_settings[active_sub_tab]" value="player_audio">
        <div class="movie-engine-card">
            <div class="movie-engine-card-header">
                <h3><span class="fa-solid fa-volume-high"></span> <?php esc_html_e('Audio Settings', 'cine-movie-engine'); ?></h3>
            </div>
            <div class="movie-engine-card-body">
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[enable_audio_selection]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[enable_audio_selection]" value="1" <?php checked($options['movie_engine_enable_audio_selection'] ?? ($options['enable_audio_selection'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Enable Audio Track Selection', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label for="default_audio_lang"><?php esc_html_e('Default Audio Language', 'cine-movie-engine'); ?></label>
                    <input type="text" id="default_audio_lang" name="movie_engine_player_settings[default_audio_lang]" value="<?php echo esc_attr($options['movie_engine_default_audio_lang'] ?? ($options['default_audio_lang'] ?? 'en')); ?>" class="movie-engine-input" placeholder="en">
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[dual_audio]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[dual_audio]" value="1" <?php checked($options['movie_engine_dual_audio'] ?? ($options['dual_audio'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Enable Dual Audio Mode', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[show_audio_btn]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[show_audio_btn]" value="1" <?php checked($options['movie_engine_show_audio_btn'] ?? ($options['show_audio_btn'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Always Show Audio Track Button', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label for="audio_delay"><?php esc_html_e('Audio Delay Adjustment (ms)', 'cine-movie-engine'); ?></label>
                    <input type="number" id="audio_delay" name="movie_engine_player_settings[audio_delay]" value="<?php echo esc_attr($options['movie_engine_audio_delay'] ?? ($options['audio_delay'] ?? 0)); ?>" class="movie-engine-input">
                    <p class="movie-engine-help-text"><?php esc_html_e('Positive or negative value to sync audio.', 'cine-movie-engine'); ?></p>
                </div>
            </div>
        </div>
<?php
    }
}
