Gregniuki commited on
Commit
6dd46b2
1 Parent(s): 420a8e8

Update templates/interface.html

Browse files
Files changed (1) hide show
  1. templates/interface.html +27 -8
templates/interface.html CHANGED
@@ -56,15 +56,34 @@
56
  <button type="button" id="close_button" onclick="closeGUI()">Exit</button>
57
  </div>
58
 
59
- {% if file_url %}
60
- <h2>Generated Audio</h2>
61
- <audio controls>
62
- <source src="{{ file_url }}" type="audio/mpeg">
63
- Your browser does not support the audio element.
64
- </audio>
65
- <a href="{{ file_url }}" download>Download Audio</a>
66
- {% endif %}
 
 
 
67
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  <script>
69
  // JavaScript function for handling the "Exit" button click
70
  function closeGUI() {
 
56
  <button type="button" id="close_button" onclick="closeGUI()">Exit</button>
57
  </div>
58
 
59
+ {% if file_url %}
60
+ <h2>Generated Audio</h2>
61
+ <audio controls id="audio-player">
62
+ <source src="{{ file_url }}" type="audio/mpeg">
63
+ Your browser does not support the audio element.
64
+ </audio>
65
+ <a href="{{ file_url }}" download>Download Audio</a>
66
+ {% endif %}
67
+
68
+
69
+
70
  </form>
71
+ <script>
72
+ // Get references to the checkbox and audio elements
73
+ const playCheckbox = document.getElementById("play");
74
+ const audioPlayer = document.getElementById("audio-player");
75
+
76
+ // Add an event listener to the checkbox
77
+ playCheckbox.addEventListener("change", function () {
78
+ // If the checkbox is checked, add the autoplay attribute
79
+ if (playCheckbox.checked) {
80
+ audioPlayer.setAttribute("autoplay", "");
81
+ } else {
82
+ // If the checkbox is unchecked, remove the autoplay attribute
83
+ audioPlayer.removeAttribute("autoplay");
84
+ }
85
+ });
86
+ </script>
87
  <script>
88
  // JavaScript function for handling the "Exit" button click
89
  function closeGUI() {