L
L
LakeForest2021-08-25 22:54:36
Vue.js
LakeForest, 2021-08-25 22:54:36

How to play download to start audio?

61269f4df2ce2027637671.png

<audio id="audio-player" controls
               :src="response"
               type="audio/wav"
               style="max-width: 100%;">
          Ваш браузер не поддерживает тег audio!
</audio>
methods: test() {
...
var v = this;
 this.connection.onmessage = function(event) {
           v.show_response = true;
           v.spinner_visible = false;
           try {
             var data = JSON.parse(event.data)
             var q = new Buffer.from(new String(data.audio_bytes).toString(), 'base64');//
             const blob = new Blob(
                    [new Uint8Array(q)],
                    {type: 'audio/wav'});
             const url = URL.createObjectURL(blob);
             console.log(url);

             v.response = url;
             const audio = document.getElementById('audio-player');
             audio.load();
           } catch (ex) {
             console.log(ex);
           }
      }
...}


Loads url in src, but doesn't allow to play... What's the matter?
For a second, it shows that it has loaded and is gray again. In all browsers.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question