Update templates/index.html
Browse files- templates/index.html +19 -17
templates/index.html
CHANGED
@@ -65,11 +65,11 @@
|
|
65 |
</div>
|
66 |
</div>
|
67 |
|
68 |
-
<!--
|
69 |
-
<button onclick="
|
70 |
class="w-full bg-green-500 hover:bg-green-600 active:bg-green-700 text-white py-4 px-6 rounded-xl transition-all duration-300 flex items-center justify-center space-x-2 font-medium focus:outline-none focus:ring-2 focus:ring-green-500/50 focus:ring-offset-2 dark:ring-offset-gray-800 mt-4">
|
71 |
-
<i class="fas fa-
|
72 |
-
<span>
|
73 |
</button>
|
74 |
</div>
|
75 |
</div>
|
@@ -164,14 +164,14 @@
|
|
164 |
});
|
165 |
}
|
166 |
|
167 |
-
function
|
168 |
const url = $('#youtubeUrl').val().trim();
|
169 |
if (!url) {
|
170 |
showError('Please enter a YouTube URL');
|
171 |
return;
|
172 |
}
|
173 |
|
174 |
-
showLoading('Preparing
|
175 |
|
176 |
$.ajax({
|
177 |
url: '/download',
|
@@ -183,20 +183,23 @@
|
|
183 |
},
|
184 |
success: function(response) {
|
185 |
const blob = new Blob([response], { type: 'audio/mp3' });
|
186 |
-
const
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
194 |
Swal.close();
|
195 |
-
showSuccess('
|
196 |
},
|
197 |
error: function(xhr) {
|
198 |
Swal.close();
|
199 |
-
showError('
|
200 |
}
|
201 |
});
|
202 |
}
|
@@ -217,6 +220,5 @@
|
|
217 |
document.documentElement.classList.add('dark');
|
218 |
}
|
219 |
</script>
|
220 |
-
</head>
|
221 |
</body>
|
222 |
</html>
|
|
|
65 |
</div>
|
66 |
</div>
|
67 |
|
68 |
+
<!-- Play Audio Button -->
|
69 |
+
<button onclick="playAudio()"
|
70 |
class="w-full bg-green-500 hover:bg-green-600 active:bg-green-700 text-white py-4 px-6 rounded-xl transition-all duration-300 flex items-center justify-center space-x-2 font-medium focus:outline-none focus:ring-2 focus:ring-green-500/50 focus:ring-offset-2 dark:ring-offset-gray-800 mt-4">
|
71 |
+
<i class="fas fa-play text-sm"></i>
|
72 |
+
<span>Start Listening</span>
|
73 |
</button>
|
74 |
</div>
|
75 |
</div>
|
|
|
164 |
});
|
165 |
}
|
166 |
|
167 |
+
function playAudio() {
|
168 |
const url = $('#youtubeUrl').val().trim();
|
169 |
if (!url) {
|
170 |
showError('Please enter a YouTube URL');
|
171 |
return;
|
172 |
}
|
173 |
|
174 |
+
showLoading('Preparing audio...');
|
175 |
|
176 |
$.ajax({
|
177 |
url: '/download',
|
|
|
183 |
},
|
184 |
success: function(response) {
|
185 |
const blob = new Blob([response], { type: 'audio/mp3' });
|
186 |
+
const audioUrl = URL.createObjectURL(blob);
|
187 |
+
|
188 |
+
const audioPlayer = document.createElement('audio');
|
189 |
+
audioPlayer.src = audioUrl;
|
190 |
+
audioPlayer.controls = true;
|
191 |
+
audioPlayer.style.width = '100%';
|
192 |
+
audioPlayer.style.marginTop = '1rem';
|
193 |
+
|
194 |
+
const videoInfoContainer = document.querySelector('#videoInfo .p-6');
|
195 |
+
videoInfoContainer.appendChild(audioPlayer);
|
196 |
+
|
197 |
Swal.close();
|
198 |
+
showSuccess('Audio is ready to play');
|
199 |
},
|
200 |
error: function(xhr) {
|
201 |
Swal.close();
|
202 |
+
showError('Failed to prepare audio');
|
203 |
}
|
204 |
});
|
205 |
}
|
|
|
220 |
document.documentElement.classList.add('dark');
|
221 |
}
|
222 |
</script>
|
|
|
223 |
</body>
|
224 |
</html>
|