project was built using vue-cli family buckets, and I wrote a music playback tag on a page:
<audio id="audio" autoplay class="hide" :src="audioUrl"></audio>
then the js section:
playRecord() { //
const audio = document.getElementById("audio");
//this.recorder.play(audio);
audio.src = this.GLOBAL.pro1_r_ip + "/sr/tmp/cache_readingcut.wav";
audio.load();
},
uploadAudio() { //
this.stopRecord();
const record = this.recorder.getBlob();
const t = this;
let data;
let reader = new window.FileReader();
reader.readAsDataURL(record);
reader.onloadend = function () {
data = reader.result;
t.$axios.post(t.GLOBAL.pro1_ip + "/readingcutupload", {
file: data
}).then(res => {
if (res.data.result === 1) {
t.success("");
} else {
t.error(res.data.msg);
}
})
};
}
then comes the question:
what I do is a function of web page recording. After the user has recorded the audio file, the front end sends the audio file to the back end, then the back end stores it in the server, and then gives me a link to the stored address, and I directly play the audio file in that link.
now the backend gives a fixed storage address, but the contents will be refreshed in real time. When I upload a new audio, it will be refreshed into a newly uploaded audio file, but I use audio to read the linked audio every time I re-record it. The words I listen to online with headphones are the same audio and are not updated in real time, but the real audio file is really updated in real time after downloading and testing. Tried two methods:
one is the .load () method to overload the audio, but has no effect
the second is to delete the audio tag every time you re-record, and then re-insert a new audio tag after the recording is completed, but it has no effect
would like to ask you if there is a good solution?
-Segmentation Line-
I"m afraid what I"m saying is too cumbersome and a little difficult to understand. To put it simply and roughly, audio"s src uses the same link, but the music in the link changes dynamically, but the headphones on the web page always listen to the same song. How to solve this problem?