<?php 
include ('includes/json_utils.php');
include ('includes/header.php');

$page_name = 'buildin_player_settings';


if (isset($_POST['submit']) && isset($_POST['data'])) {
    foreach ($_POST['data'] as $id => $fields) {
        updateJsonRecordByIdMulty($id, $fields);
    }

    echo "<script>window.location.href='" . $page_name . ".php?status=1'</script>";
}


?>

<div class="col-md-6 mx-auto ctmain-table">
    <div class="card-body">
        <div class="card text-white ctcard">
            <div class="card-header card-header-warning">
                <center>
                    <h2><i class="icon icon-bullhorn"></i> Built-in Player Settings</h2>
                </center>
            </div>
            
            <div class="card-body">
                <form method="post">
                    <div class="form-group ctinput">
                      <label class="form-label"> Built-in Player Decoder :</label>
                      <input type="hidden" name="data[24][preffile]" value="pref.using_media_codec">
                      <input type="hidden" name="data[24][preftype]" value="string">
                      <input type="hidden" name="data[24][prefname]" value="pref.using_media_codec">
                      <select name="data[24][mods]">
                        <option value="Hardware Decoder" <?php echo (getmodsbyid('24') == 'Hardware Decoder') ? 'selected' : ''; ?>>Hardware Decoder</option>
                        <option value="Software Decoder" <?php echo (getmodsbyid('24') == 'Software Decoder') ? 'selected' : ''; ?>>Software Decoder</option>
                      </select>
                    </div>

                    <div class="form-group ctinput">
                      <label class="form-label"> Buffer Size Limit :</label>
                      <input type="hidden" name="data[25][preffile]" value="pref.using_buffer_size">
                      <input type="hidden" name="data[25][preftype]" value="int">
                      <input type="hidden" name="data[25][prefname]" value="pref.using_buffer_size">
                      <select name="data[25][mods]">
                        <option value="1" <?php echo (getmodsbyid('25') == '1') ? 'selected' : ''; ?>>1</option>
                        <option value="2" <?php echo (getmodsbyid('25') == '2') ? 'selected' : ''; ?>>2</option>
                        <option value="3" <?php echo (getmodsbyid('25') == '3') ? 'selected' : ''; ?>>3</option>
                        <option value="4" <?php echo (getmodsbyid('25') == '4') ? 'selected' : ''; ?>>4</option>
                        <option value="5" <?php echo (getmodsbyid('25') == '5') ? 'selected' : ''; ?>>5</option>
                        <option value="10" <?php echo (getmodsbyid('25') == '10') ? 'selected' : ''; ?>>10</option>
                        <option value="20" <?php echo (getmodsbyid('25') == '20') ? 'selected' : ''; ?>>20</option>
                        <option value="30" <?php echo (getmodsbyid('25') == '30') ? 'selected' : ''; ?>>30</option>
                        <option value="40" <?php echo (getmodsbyid('25') == '40') ? 'selected' : ''; ?>>40</option>
                        <option value="50" <?php echo (getmodsbyid('25') == '50') ? 'selected' : ''; ?>>50</option>
                        <option value="100" <?php echo (getmodsbyid('25') == '100') ? 'selected' : ''; ?>>100</option>
                      </select>
                    </div>

                    <div class="form-group ctinput">
                      <label class="form-label"> Enable OpenSL ES (Hardware accelerated audio) :</label>
                      <input type="hidden" name="data[26][preffile]" value="pref.using_opensl_es">
                      <input type="hidden" name="data[26][preftype]" value="string">
                      <input type="hidden" name="data[26][prefname]" value="pref.using_opensl_es">
                      <select name="data[26][mods]">
                        <option value="checked" <?php echo (getmodsbyid('26') == 'checked') ? 'selected' : ''; ?>>Enable</option>
                        <option value="" <?php echo (getmodsbyid('26') == '') ? 'selected' : ''; ?>>Disable</option>
                      </select>
                    </div>


                    <div class="form-group ctinput">
                      <label class="form-label"> Enable OpenGL (OpenGL pixel format) :</label>
                      <input type="hidden" name="data[27][preffile]" value="pref.using_opengl">
                      <input type="hidden" name="data[27][preftype]" value="string">
                      <input type="hidden" name="data[27][prefname]" value="pref.using_opengl">
                      <select name="data[27][mods]">
                        <option value="checked" <?php echo (getmodsbyid('27') == 'checked') ? 'selected' : ''; ?>>Enable</option>
                        <option value="" <?php echo (getmodsbyid('27') == '') ? 'selected' : ''; ?>>Disable</option>
                      </select>
                    </div>

                    <div class="form-group ctinputform-group">
                        <center>
                            <button class="btn btn-info" name="submit" type="submit">
                                <i class="icon icon-check"></i> Submit
                            </button>
                        </center>
                    </div>
                </form>
            </div>       
        </div>
    </div>
</div>

<?php include ('includes/footer.php');?>
