Как я могу перезагружать кеш аудиоплеера HTML каждый раз, когда я нажимаю кнопку?Python

Программы на Python
Anonymous
Как я могу перезагружать кеш аудиоплеера HTML каждый раз, когда я нажимаю кнопку?

Сообщение Anonymous »

У меня есть созданный wav-файл под названием in.wav, который создается каждый раз, когда пользователь нажимает кнопку. Однако воспроизведение звука не распознает новый файл in.wav до тех пор, пока не пройдет случайное время. Я хочу, чтобы аудиоплеер обновился и проверил, отличается ли in.wav.

Код: Выделить всё

function display(textString,keyString,modeString,instrumentString, onSuccess) {
// ajax allows the function to take place without having to refresh webpage
$.ajax({
// searches for string_return in app.py
url: "string_return",
data: {
text_string: textString,
key_string : keyString,
mode_string : modeString,
instrument_string : instrumentString
},
// allows function know to return json data type and look for GET method
dataType: "json",
type: "GET",
// what this does is if the ajax request is successful, it executes the specified function in
// the parameter (in the below case, that's specified as function(returnedString))
success: function(response) {
onSuccess(response);
}
});
}
// if button with id "convert-button" is clicked...
$("#convert-button").on("click", function() {
// textString is set to the value the user inputted in the text box
let textString = $("#text-input").val();
let key = $("#key").val();
let mode = $("#mode").val();
let inst = $("#instrument").val();
// display method from above is called
display(textString, key, mode, inst,function(returnedString) {
$("#returned_string").text(returnedString);
});

const audio_player = document.getElementById("player");
audio_player.load();
});
Я знаю, что аудиоплеер перезагрузился, когда я получу

Код: Выделить всё

10.245.100.65 - - [27/Apr/2024 17:13:01] "GET /static/in.wav HTTP/1.1" 206 -
в моем приложении Flask. Итак, еще раз, как я могу вызвать перезагрузку этого аудиоплеера?
Я пытался реализовать функцию .load(), но она не думает, что она работает, и не перезагрузит новый аудиофайл. п>

Подробнее здесь: https://stackoverflow.com/questions/783 ... s-a-button

Вернуться в «Python»